Class: Feat::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/feat/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(feat, audience) ⇒ Cache

Returns a new instance of Cache.



3
4
5
6
# File 'lib/feat/cache.rb', line 3

def initialize(feat, audience)
  @feat = feat
  @audience = audience
end

Instance Method Details

#cache_to_redisObject



8
9
10
11
12
13
14
# File 'lib/feat/cache.rb', line 8

def cache_to_redis
  Feat.redis.with do |conn|
    conn.sadd('feat:cached_dates', date)
    conn.hincrby("feat:feats_on_date:#{date}", @feat, 1)
    conn.sadd("feat:audience:#{namespaced_feat}", @audience) if @audience
  end
end