+
+ it "should be able to handle array of :get using SORT" do
+ @r['dog:1:name'] = 'louie'
+ @r['dog:1:breed'] = 'mutt'
+ @r.rpush 'dogs', 1
+ @r['dog:2:name'] = 'lucy'
+ @r['dog:2:breed'] = 'poodle'
+ @r.rpush 'dogs', 2
+ @r['dog:3:name'] = 'max'
+ @r['dog:3:breed'] = 'hound'
+ @r.rpush 'dogs', 3
+ @r['dog:4:name'] = 'taj'
+ @r['dog:4:breed'] = 'terrier'
+ @r.rpush 'dogs', 4
+ @r.sort('dogs', :get => ['dog:*:name', 'dog:*:breed'], :limit => [0,1]).should == ['louie', 'mutt']
+ @r.sort('dogs', :get => ['dog:*:name', 'dog:*:breed'], :limit => [0,1], :order => 'desc alpha').should == ['taj', 'terrier']
+ end
+ #
+ it "should provide 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
+ @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 be able to provide the last save time (LASTSAVE)" do
+ savetime = @r.lastsave
+ Time.at(savetime).class.should == Time
+ Time.at(savetime).should <= Time.now
+ end
+
+ it "should be able to MGET keys" do
+ @r['foo'] = 1000
+ @r['bar'] = 2000
+ @r.mget('foo', 'bar').should == ['1000', '2000']
+ @r.mget('foo', 'bar', 'baz').should == ['1000', '2000', nil]
+ end
+
+ it "should bgsave" do
+ @r.bgsave.should == 'OK'
+ end
+
+ it "should handle multiple servers" do
+ require 'dist_redis'
+ @r = DistRedis.new(:hosts=> ['localhost:6379', '127.0.0.1:6379'], :db => 15)
+
+ 100.times do |idx|
+ @r[idx] = "foo#{idx}"
+ end
+
+ 100.times do |idx|
+ @r[idx].should == "foo#{idx}"
+ end
+ end
+
+ it "should be able to pipeline writes" do
+ @r.pipelined do |pipeline|
+ pipeline.lpush 'list', "hello"
+ pipeline.lpush 'list', 42
+ end
+
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.lpop('list').should == '42'
+ end
+
+end