Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
4e1684df
Commit
4e1684df
authored
May 20, 2009
by
antirez
Browse files
RubyRedis DB selection forced at object creation
parent
4a327b4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
client-libraries/ruby_2/rubyredis.rb
View file @
4e1684df
...
@@ -20,6 +20,7 @@ class RedisClient
...
@@ -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
...
@@ -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
...
@@ -72,3 +77,6 @@ class RedisClient
end
end
end
end
end
end
r
=
RedisClient
.
new
(
:db
=>
0
)
p
r
.
keys
(
"*"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment