]>
Commit | Line | Data |
---|---|---|
ed9b544e | 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) |