PERF: Cache About#stats.

This commit is contained in:
Guo Xiang Tan
2015-07-07 12:52:19 +08:00
parent 8be37193ee
commit b0ea6764e0
12 changed files with 121 additions and 19 deletions

View File

@@ -0,0 +1,23 @@
shared_examples_for 'stats cachable' do
describe 'fetch_cached_stats' do
it 'returns the cached stats' do
begin
stats = { "visits" => 10 }
$redis.set(described_class.stats_cache_key, stats.to_json)
expect(described_class.fetch_cached_stats).to eq(stats)
ensure
$redis.del(described_class.stats_cache_key)
end
end
it 'returns nil if no stats has been cached' do
expect(described_class.fetch_cached_stats).to eq(nil)
end
end
describe 'fetch_stats' do
it 'has been implemented' do
expect{ described_class.fetch_stats }.to_not raise_error
end
end
end