Commit 693878cf authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Cache repo size inside repo model

parent 3471e26f
...@@ -37,6 +37,22 @@ class Repository ...@@ -37,6 +37,22 @@ class Repository
raw_repository.send(m, *args, &block) raw_repository.send(m, *args, &block)
end 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) def respond_to?(method)
return true if raw_repository.respond_to?(method) return true if raw_repository.respond_to?(method)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment