diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-27 13:01:57 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-27 13:01:57 -0800 |
commit | 0d22b75b03496ced3d783f8fee9584098602ea1c (patch) | |
tree | c7ddec6072c716fd63a8703f2dfeb0e4234a633f /lib/repository_cache.rb | |
parent | 5f682094d9b7c985ad62ebe29664bb6fe87b54be (diff) | |
parent | d4aab6528cb80b0f41bdac2240dd9cc32543481d (diff) | |
download | gitlab-ce-0d22b75b03496ced3d783f8fee9584098602ea1c.tar.gz |
Merge branch 'master' into mmonaco/gitlab-ce-api-user-noconfirm
Conflicts:
lib/api/users.rb
Diffstat (limited to 'lib/repository_cache.rb')
-rw-r--r-- | lib/repository_cache.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/repository_cache.rb b/lib/repository_cache.rb new file mode 100644 index 00000000000..fa016a170cd --- /dev/null +++ b/lib/repository_cache.rb @@ -0,0 +1,21 @@ +# Interface to the Redis-backed cache store used by the Repository model +class RepositoryCache + attr_reader :namespace, :backend + + def initialize(namespace, backend = Rails.cache) + @namespace = namespace + @backend = backend + end + + def cache_key(type) + "#{type}:#{namespace}" + end + + def expire(key) + backend.delete(cache_key(key)) + end + + def fetch(key, &block) + backend.fetch(cache_key(key), &block) + end +end |