mirror of
https://github.com/fluencelabs/redis
synced 2025-08-01 00:41:56 +00:00
client libraries updated
This commit is contained in:
1
client-libraries/ruby/.gitignore
vendored
1
client-libraries/ruby/.gitignore
vendored
@@ -2,4 +2,5 @@ nohup.out
|
||||
redis/*
|
||||
rdsrv
|
||||
pkg/*
|
||||
coverage/*
|
||||
.idea
|
||||
|
@@ -8,7 +8,7 @@ require 'tasks/redis.tasks'
|
||||
|
||||
GEM = 'redis'
|
||||
GEM_NAME = 'redis'
|
||||
GEM_VERSION = '0.0.3.4'
|
||||
GEM_VERSION = '0.1'
|
||||
AUTHORS = ['Ezra Zygmuntowicz', 'Taylor Weibley', 'Matthew Clark']
|
||||
EMAIL = "ez@engineyard.com"
|
||||
HOMEPAGE = "http://github.com/ezmobius/redis-rb"
|
||||
@@ -53,4 +53,10 @@ task :make_spec do
|
||||
File.open("#{GEM}.gemspec", "w") do |file|
|
||||
file.puts spec.to_ruby
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run all examples with RCov"
|
||||
Spec::Rake::SpecTask.new(:rcov) do |t|
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
t.rcov = true
|
||||
end
|
||||
|
@@ -29,7 +29,11 @@ describe "redis" do
|
||||
@r.quit
|
||||
end
|
||||
|
||||
it 'should be able to PING' do
|
||||
it "should be able connect without a timeout" do
|
||||
lambda { Redis.new :timeout => 0 }.should_not raise_error
|
||||
end
|
||||
|
||||
it "should be able to PING" do
|
||||
@r.ping.should == 'PONG'
|
||||
end
|
||||
|
||||
@@ -61,13 +65,23 @@ describe "redis" do
|
||||
sleep 2
|
||||
@r['foo'].should == nil
|
||||
end
|
||||
|
||||
|
||||
it "should be able to return a TTL for a key" do
|
||||
@r.set('foo', 'bar', 1)
|
||||
@r.ttl('foo').should == 1
|
||||
end
|
||||
|
||||
it "should be able to SETNX" do
|
||||
@r['foo'] = 'nik'
|
||||
@r['foo'].should == 'nik'
|
||||
@r.setnx 'foo', 'bar'
|
||||
@r['foo'].should == 'nik'
|
||||
end
|
||||
#
|
||||
it "should be able to GETSET" do
|
||||
@r.getset('foo', 'baz').should == 'bar'
|
||||
@r['foo'].should == 'baz'
|
||||
end
|
||||
#
|
||||
it "should be able to INCR a key" do
|
||||
@r.del('counter')
|
||||
@@ -75,7 +89,14 @@ describe "redis" do
|
||||
@r.incr('counter').should == 2
|
||||
@r.incr('counter').should == 3
|
||||
end
|
||||
#
|
||||
#
|
||||
it "should be able to INCRBY a key" do
|
||||
@r.del('counter')
|
||||
@r.incrby('counter', 1).should == 1
|
||||
@r.incrby('counter', 2).should == 3
|
||||
@r.incrby('counter', 3).should == 6
|
||||
end
|
||||
#
|
||||
it "should be able to DECR a key" do
|
||||
@r.del('counter')
|
||||
@r.incr('counter').should == 1
|
||||
@@ -137,6 +158,10 @@ describe "redis" do
|
||||
@r['foo'] = 'qux'
|
||||
@r.keys("f*").sort.should == ['f','fo', 'foo'].sort
|
||||
end
|
||||
#
|
||||
it "should be able to return a random key (RANDOMKEY)" do
|
||||
3.times { @r.exists(@r.randomkey).should be_true }
|
||||
end
|
||||
#BTM - TODO
|
||||
it "should be able to check the TYPE of a key" do
|
||||
@r['foo'] = 'nik'
|
||||
@@ -356,20 +381,24 @@ describe "redis" do
|
||||
@r.sort('dogs', :get => ['dog:*:name', 'dog:*:breed'], :limit => [0,1], :order => 'desc alpha').should == ['taj', 'terrier']
|
||||
end
|
||||
#
|
||||
it "should provide info" do
|
||||
it "should provide info (INFO)" do
|
||||
[:last_save_time, :redis_version, :total_connections_received, :connected_clients, :total_commands_processed, :connected_slaves, :uptime_in_seconds, :used_memory, :uptime_in_days, :changes_since_last_save].each do |x|
|
||||
@r.info.keys.should include(x)
|
||||
end
|
||||
end
|
||||
#
|
||||
it "should be able to flush the database" do
|
||||
it "should be able to flush the database (FLUSHDB)" do
|
||||
@r['key1'] = 'keyone'
|
||||
@r['key2'] = 'keytwo'
|
||||
@r.keys('*').sort.should == ['foo', 'key1', 'key2'].sort #foo from before
|
||||
@r.flushdb
|
||||
@r.keys('*').should == []
|
||||
end
|
||||
#
|
||||
#
|
||||
it "should raise exception when manually try to change the database" do
|
||||
lambda { @r.select(0) }.should raise_error
|
||||
end
|
||||
#
|
||||
it "should be able to provide the last save time (LASTSAVE)" do
|
||||
savetime = @r.lastsave
|
||||
Time.at(savetime).class.should == Time
|
||||
@@ -387,6 +416,10 @@ describe "redis" do
|
||||
@r.bgsave.should == 'OK'
|
||||
end
|
||||
|
||||
it "should should be able to ECHO" do
|
||||
@r.echo("message in a bottle\n").should == "message in a bottle\n"
|
||||
end
|
||||
|
||||
it "should handle multiple servers" do
|
||||
require 'dist_redis'
|
||||
@r = DistRedis.new(:hosts=> ['localhost:6379', '127.0.0.1:6379'], :db => 15)
|
||||
|
Reference in New Issue
Block a user