Skip to content

Commit

Permalink
Aliases for #[] and #[]=
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Feb 14, 2012
1 parent 969f391 commit ad88576
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/redis.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def get(key)
end end
end end


alias :[] :get

# Returns the bit value at offset in the string value stored at key. # Returns the bit value at offset in the string value stored at key.
def getbit(key, offset) def getbit(key, offset)
synchronize do synchronize do
Expand Down Expand Up @@ -864,21 +866,15 @@ def sync
end end
end end


def [](key)
get(key)
end

def []=(key,value)
set(key, value)
end

# Set the string value of a key. # Set the string value of a key.
def set(key, value) def set(key, value)
synchronize do synchronize do
@client.call [:set, key, value] @client.call [:set, key, value]
end end
end end


alias :[]= :set

# Sets or clears the bit at offset in the string value stored at key. # Sets or clears the bit at offset in the string value stored at key.
def setbit(key, offset, value) def setbit(key, offset, value)
synchronize do synchronize do
Expand Down

0 comments on commit ad88576

Please sign in to comment.