]> git.saurik.com Git - redis.git/blob - client-libraries/ruby/examples/list.rb
Ruby client updated
[redis.git] / client-libraries / ruby / examples / list.rb
1 require 'rubygems'
2 require 'redis'
3
4 r = Redis.new
5
6 r.delete 'logs'
7
8 puts
9
10 p "pushing log messages into a LIST"
11 r.push_tail 'logs', 'some log message'
12 r.push_tail 'logs', 'another log message'
13 r.push_tail 'logs', 'yet another log message'
14 r.push_tail 'logs', 'also another log message'
15
16 puts
17 p 'contents of logs LIST'
18
19 p r.list_range('logs', 0, -1)
20
21 puts
22 p 'Trim logs LIST to last 2 elements(easy circular buffer)'
23
24 r.list_trim('logs', -2, -1)
25
26 p r.list_range('logs', 0, -1)