summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-07-18 20:17:24 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-07-18 20:17:24 +0800
commit3c34a0b99be2cf858831043403ba2268ac270c77 (patch)
treeb0d8239fc268a6e42c8c0dbc7874d8d85d723183 /lib
parent3c7cb6ad9e9d74c0f2fb7e8ba19f258c7316f445 (diff)
downloadgitlab-ce-3c34a0b99be2cf858831043403ba2268ac270c77.tar.gz
Remove old request store wrap
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/cache/request_store_wrap.rb60
1 files changed, 0 insertions, 60 deletions
diff --git a/lib/gitlab/cache/request_store_wrap.rb b/lib/gitlab/cache/request_store_wrap.rb
deleted file mode 100644
index 3e0a5f06b53..00000000000
--- a/lib/gitlab/cache/request_store_wrap.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-module Gitlab
- module Cache
- # This module provides a simple way to cache values in RequestStore,
- # and the cache key would be based on the class name, method name,
- # customized instance level values, and arguments.
- #
- # A simple example:
- #
- # class UserAccess
- # extend Gitlab::Cache::RequestStoreWrap
- #
- # request_store_wrap_key do
- # [user.id, project.id]
- # end
- #
- # request_store_wrap def can_push_to_branch?(ref)
- # # ...
- # end
- # end
- #
- # This way, the result of `can_push_to_branch?` would be cached in
- # `RequestStore.store` based on the cache key.
- module RequestStoreWrap
- def self.extended(klass)
- return if klass < self
-
- extension = Module.new
- klass.const_set(:RequestStoreWrapExtension, extension)
- klass.prepend(extension)
- end
-
- def request_store_wrap_key(&block)
- if block_given?
- @request_store_wrap_key = block
- else
- @request_store_wrap_key
- end
- end
-
- def request_store_wrap(method_name)
- const_get(:RequestStoreWrapExtension)
- .send(:define_method, method_name) do |*args|
- return super(*args) unless RequestStore.active?
-
- klass = self.class
- key = [klass.name,
- method_name,
- *instance_exec(&klass.request_store_wrap_key),
- *args].join(':')
-
- if RequestStore.store.key?(key)
- RequestStore.store[key]
- else
- RequestStore.store[key] = super(*args)
- end
- end
- end
- end
- end
-end