Class: EventsEmitter::Redis
- Inherits:
-
Object
- Object
- EventsEmitter::Redis
- Defined in:
- lib/events_emitter/redis.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.config ⇒ Object
28 29 30 |
# File 'lib/events_emitter/redis.rb', line 28 def self.config @config ||= { host: "127.0.0.1", port: 6379, db: 1 } end |
Instance Method Details
#get(key) ⇒ Object
22 23 24 25 26 |
# File 'lib/events_emitter/redis.rb', line 22 def get(key) storage.smembers(key).map do |e| JSON.parse(e) end end |
#record(key, value) ⇒ Object
18 19 20 |
# File 'lib/events_emitter/redis.rb', line 18 def record(key, value) storage.sadd(key, value.to_json) end |
#storage ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/events_emitter/redis.rb', line 6 def storage return @storage if @storage opts = { :host => self.class.config[:host], :port => self.class.config[:port], :db => self.class.config[:db] } @storage = ::Redis.new(opts) end |