mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 10:08:20 -05:00
25 lines
545 B
Ruby
25 lines
545 B
Ruby
|
module StatsCacheable
|
||
|
extend ActiveSupport::Concern
|
||
|
|
||
|
module ClassMethods
|
||
|
def stats_cache_key
|
||
|
raise 'Stats cache key has not been set.'
|
||
|
end
|
||
|
|
||
|
def fetch_stats
|
||
|
raise 'Not implemented.'
|
||
|
end
|
||
|
|
||
|
# Could be configurable, multisite need to support it.
|
||
|
def recalculate_stats_interval
|
||
|
30 # minutes
|
||
|
end
|
||
|
|
||
|
def fetch_cached_stats
|
||
|
# The scheduled Stats job is responsible for generating and caching this.
|
||
|
stats = $redis.get(stats_cache_key)
|
||
|
stats ? JSON.parse(stats) : nil
|
||
|
end
|
||
|
end
|
||
|
end
|