]> git.saurik.com Git - redis.git/blobdiff - client-libraries/ruby_2/rubyredis.rb
RubyRedis: Array alike operators implemented
[redis.git] / client-libraries / ruby_2 / rubyredis.rb
index 958210dcd58a77bda86e47f99d1afe31d75c2f23..9be390e3eaba8afb992ededb7feb8f74e648cedb 100644 (file)
@@ -20,6 +20,7 @@ class RedisClient
         @port = opts[:port]
         @db = opts[:db]
         @sock = connect_to_server
         @port = opts[:port]
         @db = opts[:db]
         @sock = connect_to_server
+        call_command(["select",@db]) if @db != 0
     end
 
     def to_s
     end
 
     def to_s
@@ -46,6 +47,18 @@ class RedisClient
         read_reply
     end
 
         read_reply
     end
 
+    def select(*args)
+        raise "SELECT not allowed, use the :db option when creating the object"
+    end
+
+    def [](key)
+        get(key)
+    end
+
+    def []=(key,value)
+        set(key,value)
+    end
+
     def read_reply
         line = @sock.gets
         case line[0..0]
     def read_reply
         line = @sock.gets
         case line[0..0]