Class: Socrates::Storage::Redis
- Inherits:
-
Object
- Object
- Socrates::Storage::Redis
show all
- Includes:
- Storage
- Defined in:
- lib/socrates/storage/redis.rb
Instance Method Summary
collapse
Methods included from Storage
#clear_all, #fetch, #generate_key, #persist
Constructor Details
#initialize(url: "redis://localhost") ⇒ Redis
Returns a new instance of Redis.
10
11
12
|
# File 'lib/socrates/storage/redis.rb', line 10
def initialize(url: "redis://localhost")
@redis = ::Redis.new(url: url)
end
|
Instance Method Details
#clear(key) ⇒ Object
18
19
20
|
# File 'lib/socrates/storage/redis.rb', line 18
def clear(key)
@redis.del(key)
end
|
#get(key) ⇒ Object
22
23
24
|
# File 'lib/socrates/storage/redis.rb', line 22
def get(key)
@redis.get(key)
end
|
#has_key?(key) ⇒ Boolean
14
15
16
|
# File 'lib/socrates/storage/redis.rb', line 14
def has_key?(key)
@redis.exists?(key)
end
|
#put(key, value) ⇒ Object
26
27
28
|
# File 'lib/socrates/storage/redis.rb', line 26
def put(key, value)
@redis.set(key, value)
end
|