Skip to content
Snippets Groups Projects
Commit 693878cf authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Cache repo size inside repo model

parent 3471e26f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -37,6 +37,22 @@ class Repository
raw_repository.send(m, *args, &block)
end
 
# Return repo size in megabytes
# Cached in redis
def size
Rails.cache.fetch(cache_key(:size)) do
raw_repository.size
end
end
def expire_cache
Rails.cache.delete(cache_key(:size))
end
def cache_key(type)
"#{type}:#{path_with_namespace}"
end
def respond_to?(method)
return true if raw_repository.respond_to?(method)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment