Class: RedisWebManager::Data

Inherits:
Base
  • Object
show all
Defined in:
lib/redis_web_manager/data.rb

Constant Summary collapse

BASE =
'RedisWebManager'

Instance Attribute Summary

Attributes inherited from Base

#instance

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RedisWebManager::Base

Instance Method Details

#flushObject



17
18
19
# File 'lib/redis_web_manager/data.rb', line 17

def flush
  data.map { |key| redis.del(key) }
end

#keysObject



7
8
9
# File 'lib/redis_web_manager/data.rb', line 7

def keys
  data.map { |key| JSON.parse(redis.get(key), symbolize_names: true) }
end

#performObject



11
12
13
14
15
# File 'lib/redis_web_manager/data.rb', line 11

def perform
  now = Time.now.to_i
  seconds = (now + lifespan.to_i) - now
  redis.setex("#{BASE}_#{instance}_#{now}", seconds, serialize.to_json)
end