mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
RubyRedis DB selection forced at object creation
This commit is contained in:
parent
4a327b4af9
commit
4e1684df09
@ -20,6 +20,7 @@ class RedisClient
|
|||||||
@port = opts[:port]
|
@port = opts[:port]
|
||||||
@db = opts[:db]
|
@db = opts[:db]
|
||||||
@sock = connect_to_server
|
@sock = connect_to_server
|
||||||
|
call_command(["select",@db]) if @db != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
@ -46,6 +47,10 @@ class RedisClient
|
|||||||
read_reply
|
read_reply
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def select(*args)
|
||||||
|
raise "SELECT not allowed, use the :db option when creating the object"
|
||||||
|
end
|
||||||
|
|
||||||
def read_reply
|
def read_reply
|
||||||
line = @sock.gets
|
line = @sock.gets
|
||||||
case line[0..0]
|
case line[0..0]
|
||||||
@ -72,3 +77,6 @@ class RedisClient
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
r = RedisClient.new(:db=>0)
|
||||||
|
p r.keys("*")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user