Class: Xunch::Cache

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

Instance Method Summary collapse

Constructor Details

#initialize(options, shard_infos) ⇒ Cache

Returns a new instance of Cache.



4
5
6
7
# File 'lib/xunch/cache/cache.rb', line 4

def initialize(options, shard_infos)
  @options = initialize_options(options)
  @shard_redis = ShardRedis.new(@options[:regex],shard_infos)
end

Instance Method Details

#batch_evict(keys) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/xunch/cache/cache.rb', line 13

def batch_evict(keys)
  new_keys = []
  keys.each { |key|
    new_keys.push assembleKey(key)
  }
  @shard_redis.batch_del(new_keys)
end

#destroyObject



21
22
23
# File 'lib/xunch/cache/cache.rb', line 21

def destroy
  @shard_redis.destroy
end

#evict(key) ⇒ Object



9
10
11
# File 'lib/xunch/cache/cache.rb', line 9

def evict(key)
  @shard_redis.del(assembleKey(key))
end