Permalink
Browse files

Document INCR family

  • Loading branch information...
1 parent 284e29c commit 74d9ca63c8209415cdd933089a33af5011719b36 @pietern pietern committed Mar 9, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/redis.rb
View
@@ -1654,27 +1654,57 @@ def sort(key, options = {})
end
# Increment the integer value of a key by one.
+ #
+ # @example
+ # redis.incr("value")
+ # # => 6
+ #
+ # @param [String] key
+ # @return [Fixnum] value after incrementing it
def incr(key)
synchronize do
@client.call [:incr, key]
end
end
# Increment the integer value of a key by the given number.
+ #
+ # @example
+ # redis.incrby("value", 5)
+ # # => 10
+ #
+ # @param [String] key
+ # @param [Fixnum] increment
+ # @return [Fixnum] value after incrementing it
def incrby(key, increment)
synchronize do
@client.call [:incrby, key, increment]
end
end
# Decrement the integer value of a key by one.
+ #
+ # @example
+ # redis.decr("value")
+ # # => 4
+ #
+ # @param [String] key
+ # @return [Fixnum] value after decrementing it
def decr(key)
synchronize do
@client.call [:decr, key]
end
end
# Decrement the integer value of a key by the given number.
+ #
+ # @example
+ # redis.decrby("value", 5)
+ # # => 0
+ #
+ # @param [String] key
+ # @param [Fixnum] decrement
+ # @return [Fixnum] value after decrementing it
def decrby(key, decrement)
synchronize do
@client.call [:decrby, key, decrement]

0 comments on commit 74d9ca6

Please sign in to comment.