Class: Pause::Redis::ShardedAdapter
- Defined in:
- lib/pause/redis/sharded_adapter.rb
Overview
This class encapsulates Redis operations used by Pause. Operations that are not possible when data is sharded raise an error.
Instance Attribute Summary
Attributes inherited from Adapter
#history, #resolution, #time_blocks_to_keep
Instance Method Summary collapse
Methods inherited from Adapter
#all_keys, #delete_rate_limited_key, #delete_rate_limited_keys, #disable, #disabled?, #enable, #enabled?, #expire_block_list, #initialize, #key_history, #rate_limit!, #rate_limited?, #rate_limited_keys
Methods included from Helper::Timing
Constructor Details
This class inherits a constructor from Pause::Redis::Adapter
Instance Method Details
#increment(scope, identifier, timestamp, count = 1) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pause/redis/sharded_adapter.rb', line 10 def increment(scope, identifier, , count = 1) k = tracked_key(scope, identifier) redis.zincrby k, count, period_marker(resolution, ) redis.expire k, history if redis.zcard(k) > time_blocks_to_keep list = extract_set_elements(k) to_remove = list.slice(0, (list.size - time_blocks_to_keep)) redis.zrem(k, to_remove.map(&:ts)) end end |