Class: Cinch::Plugins::LastSeen::RedisStorage
- Inherits:
-
Object
- Object
- Cinch::Plugins::LastSeen::RedisStorage
- Defined in:
- lib/cinch/plugins/last_seen/storage/redis_storage.rb
Instance Attribute Summary collapse
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #get_time(set, key) ⇒ Object
-
#initialize ⇒ RedisStorage
constructor
A new instance of RedisStorage.
- #record_time(set, key) ⇒ Object
Constructor Details
#initialize ⇒ RedisStorage
Returns a new instance of RedisStorage.
13 14 15 |
# File 'lib/cinch/plugins/last_seen/storage/redis_storage.rb', line 13 def initialize @redis = ::Redis::Namespace.new("cinch-seen_last", :redis => ::Redis.new(:thread_safe => true)) end |
Instance Attribute Details
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
11 12 13 |
# File 'lib/cinch/plugins/last_seen/storage/redis_storage.rb', line 11 def redis @redis end |
Instance Method Details
#get_time(set, key) ⇒ Object
21 22 23 24 |
# File 'lib/cinch/plugins/last_seen/storage/redis_storage.rb', line 21 def get_time(set, key) time = redis.zscore(set, key) Time.at(time.to_i) if time end |
#record_time(set, key) ⇒ Object
17 18 19 |
# File 'lib/cinch/plugins/last_seen/storage/redis_storage.rb', line 17 def record_time(set, key) redis.zadd(set.to_s, Time.now.to_i, key.to_s) end |