Class: Socrates::Storage::RedisStorage
- Inherits:
-
Object
- Object
- Socrates::Storage::RedisStorage
- Defined in:
- lib/socrates/storage/storage.rb
Instance Method Summary collapse
- #clear(key) ⇒ Object
- #get(key) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(url: "redis://localhost") ⇒ RedisStorage
constructor
A new instance of RedisStorage.
- #put(key, value) ⇒ Object
Constructor Details
#initialize(url: "redis://localhost") ⇒ RedisStorage
Returns a new instance of RedisStorage.
29 30 31 |
# File 'lib/socrates/storage/storage.rb', line 29 def initialize(url: "redis://localhost") @redis = Redis.new(url: url) end |
Instance Method Details
#clear(key) ⇒ Object
37 38 39 |
# File 'lib/socrates/storage/storage.rb', line 37 def clear(key) @redis.del key end |
#get(key) ⇒ Object
41 42 43 |
# File 'lib/socrates/storage/storage.rb', line 41 def get(key) @redis.get(key) end |
#has_key?(key) ⇒ Boolean
33 34 35 |
# File 'lib/socrates/storage/storage.rb', line 33 def has_key?(key) @redis.exists(key) end |
#put(key, value) ⇒ Object
45 46 47 |
# File 'lib/socrates/storage/storage.rb', line 45 def put(key, value) @redis.set(key, value) end |