Class: ArRedis::Base
- Inherits:
-
Object
- Object
- ArRedis::Base
- Defined in:
- lib/ar_redis/base.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#redis_client ⇒ Object
readonly
Returns the value of attribute redis_client.
Instance Method Summary collapse
- #[](next_key) ⇒ Object
- #call(command, *arguments) ⇒ Object
- #delete_all ⇒ Object
-
#initialize(key) ⇒ Base
constructor
A new instance of Base.
- #to_s ⇒ Object
Constructor Details
#initialize(key) ⇒ Base
5 6 7 8 |
# File 'lib/ar_redis/base.rb', line 5 def initialize(key) @key = key.to_s @redis_client = ArRedis.redis end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/ar_redis/base.rb', line 3 def key @key end |
#redis_client ⇒ Object (readonly)
Returns the value of attribute redis_client.
3 4 5 |
# File 'lib/ar_redis/base.rb', line 3 def redis_client @redis_client end |
Instance Method Details
#[](next_key) ⇒ Object
10 11 12 |
# File 'lib/ar_redis/base.rb', line 10 def [](next_key) ArRedis::Base.new("#{key}:#{next_key}") end |
#call(command, *arguments) ⇒ Object
14 15 16 |
# File 'lib/ar_redis/base.rb', line 14 def call(command, *arguments) redis_client.call(command, key, *arguments) end |
#delete_all ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ar_redis/base.rb', line 18 def delete_all keys = redis_client.keys("#{self}*") unless keys.blank? redis_client.del(keys) end end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/ar_redis/base.rb', line 26 def to_s key end |