Skip to content

Commit

Permalink
Document auth, select and other strings/lists commands
Browse files Browse the repository at this point in the history
  • Loading branch information
matflores committed Mar 9, 2012
1 parent 8012858 commit fd9050f
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions lib/redis.rb
Expand Up @@ -63,13 +63,20 @@ def without_reconnect(&block)
end

# Authenticate to the server.
#
# @param [String] password must match the password specified in the
# `requirepass` directive in the configuration file
# @return [String] `OK`
def auth(password)
synchronize do
@client.call [:auth, password]
end
end

# Change the selected database for the current connection.
#
# @param [Fixnum] db zero-based index of the DB to use (0 to 15)
# @return [String] `OK`
def select(db)
synchronize do
@client.db = db
Expand Down Expand Up @@ -146,7 +153,7 @@ def save

# Asynchronously save the dataset to disk.
#
# @return [String]
# @return [String] `OK`
def bgsave
synchronize do
@client.call [:bgsave]
Expand All @@ -155,7 +162,7 @@ def bgsave

# Asynchronously rewrite the append-only file.
#
# @return [String]
# @return [String] `OK`
def bgrewriteaof
synchronize do
@client.call [:bgrewriteaof]
Expand Down Expand Up @@ -186,6 +193,12 @@ def getbit(key, offset)
end

# Get a substring of the string stored at a key.
#
# @param [String] key
# @param [Fixnum] start zero-based start offset
# @param [Fixnum] stop zero-based end offset. Use -1 for representing
# the end of the string
# @return [Fixnum] `0` or `1`
def getrange(key, start, stop)
synchronize do
@client.call [:getrange, key, start, stop]
Expand All @@ -196,7 +209,8 @@ def getrange(key, start, stop)
#
# @param [String] key
# @param [String] value value to replace the current value with
# @return [String]
# @return [String] the old value stored in the key, or `nil` if the key
# did not exist
def getset(key, value)
synchronize do
@client.call [:getset, key, value]
Expand Down Expand Up @@ -227,7 +241,8 @@ def append(key, value)
# Get the length of the value stored in a key.
#
# @param [String] key
# @return [Fixnum]
# @return [Fixnum] the length of the value stored in the key, or 0
# if the key does not exist
def strlen(key)
synchronize do
@client.call [:strlen, key]
Expand Down Expand Up @@ -257,6 +272,7 @@ def hgetall(key)
# Get the value of a hash field.
#
# @param [String] key
# @param [String] field
# @return [String]
def hget(key, field)
synchronize do
Expand Down Expand Up @@ -431,7 +447,10 @@ def lset(key, index, value)
# Remove elements from a list.
#
# @param [String] key
# @param [Fixnum] count
# @param [Fixnum] count number of elements to remove. Use a positive
# value to remove the first `count` occurrences of `value`. A negative
# value to remove the last `count` occurrences of `value`. Or zero, to
# remove all occurrences of `value` from the list.
# @param [String] value
# @return [Fixnum] the number of removed elements
def lrem(key, count, value)
Expand All @@ -440,7 +459,7 @@ def lrem(key, count, value)
end
end

# Append one or more values to a list.
# Append one or more values to a list, creating the list if it doesn't exist
#
# @param [String] key
# @param [String] value
Expand All @@ -462,7 +481,7 @@ def rpushx(key, value)
end
end

# Prepend one or more values to a list.
# Prepend one or more values to a list, creating the list if it doesn't exist
#
# @param [String] key
# @param [String] value
Expand Down Expand Up @@ -578,6 +597,7 @@ def smembers(key)
# Determine if a given value is a member of a set.
#
# @param [String] key
# @param [String] member
# @return [Boolean]
def sismember(key, member)
synchronize do
Expand Down Expand Up @@ -829,7 +849,7 @@ def zrevrank(key, member)
# @param [String] key
# @param [Float] increment
# @param [String] member
# @return [Float] score of the member after the incrementing it
# @return [Float] score of the member after incrementing it
def zincrby(key, increment, member)
synchronize do
@client.call [:zincrby, key, increment, member] do |reply|
Expand Down

0 comments on commit fd9050f

Please sign in to comment.