revans (owner)

Revisions

gist: 228152 Download_button fork
public
Public Clone URL: git://gist.github.com/228152.git
Embed All Files: show embed
Ezra_MountainWest_09.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'rubygems'
require 'redis'
 
r = Redis.new
 
p 'set foo to "bar"'
r['foo'] = 'bar'
 
p 'value of foo'
p r['foo']
 
puts
p '*' * 80
 
p 'incr'
r.delete 'counter'
 
p r.incr('counter')
p r.incr('counter')
p r.incr('counter')
 
p 'decr'
p r.decr('counter')
p r.decr('counter')
p r.decr('counter')
 
r.delete 'logs'
 
puts
p '*' * 80
 
p "pushing log messages into a LIST"
r.push_tail 'logs', 'some log message'
r.push_tail 'logs', 'another log message'
r.push_tail 'logs', 'yet another log message'
r.push_tail 'logs', 'also another log message'
 
puts
p '*' * 80
p 'contents of logs LIST'
 
p r.list_range 'logs', 0, -1
 
puts
p '*' * 80
p 'Trim logs LIST to last 2 elements(easy circular buffer)'
 
p r.list_range 'logs', 0, -1
 
puts
p '*' * 80
p 'create a set of tags on foo-tags'
 
r.set_add 'foo-tags', 'one'
r.set_add 'foo-tags', 'two'
r.set_add 'foo-tags', 'three'
 
puts
p '*' * 80
p "create a set of tags on bar-tags"
 
r.set_add 'bar-tags', 'three'
r.set_add 'bar-tags', 'four'
r.set_add 'bar-tags', 'five'
 
 
puts
p '*' * 80
p 'foo-tags'
 
p r.set_members 'foo-tags'
 
puts
p '*' * 80
p 'bar-tags'
 
p r.set_members 'bar-tags'
 
 
puts
p '*' * 80
p 'intersection of foo-tags and bar-tags'
 
p r.set_intersect 'foo-tags', 'bar-tags
 
 
'