Class: ArRedis::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ar_redis/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/ar_redis/base.rb', line 3

def key
  @key
end

#redis_clientObject (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_allObject



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_sObject



26
27
28
# File 'lib/ar_redis/base.rb', line 26

def to_s
  key
end