Class: Rembrandt::Stores::Redis
- Inherits:
-
Object
- Object
- Rembrandt::Stores::Redis
- Includes:
- Fetchable
- Defined in:
- lib/rembrandt/stores/redis.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #flush ⇒ Object
-
#initialize(url = nil) ⇒ Redis
constructor
A new instance of Redis.
- #read(key) ⇒ Object
- #write(key, data) ⇒ Object
Methods included from Fetchable
Constructor Details
#initialize(url = nil) ⇒ Redis
Returns a new instance of Redis.
11 12 13 14 |
# File 'lib/rembrandt/stores/redis.rb', line 11 def initialize(url = nil) @url = ENV['REMBRANDT_REDIS_URL'] @database = ::Redis.new(:url => url) end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
9 10 11 |
# File 'lib/rembrandt/stores/redis.rb', line 9 def database @database end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/rembrandt/stores/redis.rb', line 9 def url @url end |
Instance Method Details
#available? ⇒ Boolean
16 17 18 |
# File 'lib/rembrandt/stores/redis.rb', line 16 def available? defined?(::Redis) end |
#flush ⇒ Object
28 29 30 |
# File 'lib/rembrandt/stores/redis.rb', line 28 def flush database.flushdb end |
#read(key) ⇒ Object
24 25 26 |
# File 'lib/rembrandt/stores/redis.rb', line 24 def read(key) database.get(key) end |
#write(key, data) ⇒ Object
20 21 22 |
# File 'lib/rembrandt/stores/redis.rb', line 20 def write(key, data) database.set(key, data) end |