mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 08:41:21 +00:00
first commit
This commit is contained in:
16
client-libraries/ruby/examples/basic.rb
Normal file
16
client-libraries/ruby/examples/basic.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require 'rubygems'
|
||||
require 'redis'
|
||||
|
||||
r = Redis.new
|
||||
|
||||
r.delete('foo')
|
||||
|
||||
puts
|
||||
|
||||
p'set foo to "bar"'
|
||||
r['foo'] = 'bar'
|
||||
|
||||
puts
|
||||
|
||||
p 'value of foo'
|
||||
p r['foo']
|
18
client-libraries/ruby/examples/incr-decr.rb
Normal file
18
client-libraries/ruby/examples/incr-decr.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require 'rubygems'
|
||||
require 'redis'
|
||||
|
||||
r = Redis.new
|
||||
|
||||
puts
|
||||
p 'incr'
|
||||
r.delete 'counter'
|
||||
|
||||
p r.incr('counter')
|
||||
p r.incr('counter')
|
||||
p r.incr('counter')
|
||||
|
||||
puts
|
||||
p 'decr'
|
||||
p r.decr('counter')
|
||||
p r.decr('counter')
|
||||
p r.decr('counter')
|
26
client-libraries/ruby/examples/list.rb
Normal file
26
client-libraries/ruby/examples/list.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require 'rubygems'
|
||||
require 'redis'
|
||||
|
||||
r = Redis.new
|
||||
|
||||
r.delete 'logs'
|
||||
|
||||
puts
|
||||
|
||||
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 'contents of logs LIST'
|
||||
|
||||
p r.list_range('logs', 0, -1)
|
||||
|
||||
puts
|
||||
p 'Trim logs LIST to last 2 elements(easy circular buffer)'
|
||||
|
||||
r.list_trim('logs', -2, -1)
|
||||
|
||||
p r.list_range('logs', 0, -1)
|
36
client-libraries/ruby/examples/sets.rb
Normal file
36
client-libraries/ruby/examples/sets.rb
Normal file
@ -0,0 +1,36 @@
|
||||
require 'rubygems'
|
||||
require 'redis'
|
||||
|
||||
r = Redis.new
|
||||
|
||||
r.delete 'foo-tags'
|
||||
r.delete 'bar-tags'
|
||||
|
||||
puts
|
||||
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 "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 'foo-tags'
|
||||
|
||||
p r.set_members('foo-tags')
|
||||
|
||||
puts
|
||||
p 'bar-tags'
|
||||
|
||||
p r.set_members('bar-tags')
|
||||
|
||||
puts
|
||||
p 'intersection of foo-tags and bar-tags'
|
||||
|
||||
p r.set_intersect('foo-tags', 'bar-tags')
|
Reference in New Issue
Block a user