Class: RedisArray::RedisHashGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/redisarray/redis_hash_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RedisHashGroup

Returns a new instance of RedisHashGroup.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/redisarray/redis_hash_group.rb', line 5

def initialize options={}
  options.reverse_merge!(:existing_group_name => nil)
  if options[:prefix]
    @name = options[:prefix] + "-" + rand(100000).to_s
    while not RedisTable.get_redis.keys("#{@name}:*").empty? do
      @name = options[:prefix] + "-" + rand(100000).to_s
    end
  elsif options[:existing_group_name].nil?
    @name = rand(100000).to_s
    while not RedisTable.get_redis.keys("#{@name}:*").empty? do
      @name = rand(100000).to_s
    end
  else
    @name = options[:existing_group_name].to_s
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/redisarray/redis_hash_group.rb', line 3

def name
  @name
end