Class: Chimera::RedisObjectProxy::List

Inherits:
Collection show all
Defined in:
lib/chimera/redis_objects.rb

Instance Attribute Summary

Attributes inherited from Base

#extra_opts, #name, #owner

Instance Method Summary collapse

Methods inherited from Collection

#sort

Methods inherited from Base

#connection, #decode, #destroy, #encode, #initialize, #key

Constructor Details

This class inherits a constructor from Chimera::RedisObjectProxy::Base

Instance Method Details

#<<(val) ⇒ Object



256
257
258
# File 'lib/chimera/redis_objects.rb', line 256

def <<(val)
  rpush(val)
end

#[](index) ⇒ Object



285
286
287
# File 'lib/chimera/redis_objects.rb', line 285

def [](index)
  self.index(index)
end

#index(index) ⇒ Object



281
282
283
# File 'lib/chimera/redis_objects.rb', line 281

def index(index)
  decode connection.lindex(self.key, index.to_i)
end

#lenObject Also known as: size, count



266
267
268
# File 'lib/chimera/redis_objects.rb', line 266

def len
  connection.len(self.key).to_i
end

#lpopObject Also known as: left_pop, pop



297
298
299
# File 'lib/chimera/redis_objects.rb', line 297

def lpop
  decode connection.lpop(self.key)
end

#lpush(val) ⇒ Object Also known as: left_push



260
261
262
# File 'lib/chimera/redis_objects.rb', line 260

def lpush(val)
  connection.lpush(self.key, encode(val))
end

#range(start_index, end_index) ⇒ Object



273
274
275
# File 'lib/chimera/redis_objects.rb', line 273

def range(start_index, end_index)
  (connection.lrange(self.key, start_index.to_i, end_index.to_i) || []).collect { |val| decode(val) }
end

#rem(val, count = 0) ⇒ Object



293
294
295
# File 'lib/chimera/redis_objects.rb', line 293

def rem(val, count=0)
  connection.lrem(self.key, count.to_i, encode(val))
end

#rpopObject Also known as: right_pop



304
305
306
# File 'lib/chimera/redis_objects.rb', line 304

def rpop
  decode connection.rpop(self.key)
end

#rpoplpush(dest_key) ⇒ Object Also known as: right_pop_left_push



310
311
312
# File 'lib/chimera/redis_objects.rb', line 310

def rpoplpush(dest_key)
  decode connection.rpoplpush(self.key, dest_key)
end

#rpush(val) ⇒ Object Also known as: right_push



250
251
252
# File 'lib/chimera/redis_objects.rb', line 250

def rpush(val)
  connection.rpush(self.key, encode(val))
end

#set(index, val) ⇒ Object



289
290
291
# File 'lib/chimera/redis_objects.rb', line 289

def set(index, val)
  connection.lset(self.key, index.to_i, encode(val))
end

#trim(start_index, end_index) ⇒ Object



277
278
279
# File 'lib/chimera/redis_objects.rb', line 277

def trim(start_index, end_index)
  connection.ltrim(self.key, start_index.to_i, end_index.to_i)
end