Module: Protocol::Redis::Methods::Hashes

Defined in:
lib/protocol/redis/methods/hashes.rb

Instance Method Summary collapse

Instance Method Details

#hdel(key, *fields) ⇒ Object

Delete one or more hash fields. O(N) where N is the number of fields to be removed.

Parameters:

  • key (Key)
  • field (String)

See Also:



77
78
79
# File 'lib/protocol/redis/methods/hashes.rb', line 77

def hdel(key, *fields)
	call('HDEL', key, *fields)
end

#hexists(key, field) ⇒ Object

Determine if a hash field exists. O(1).

Parameters:

  • key (Key)
  • field (String)

See Also:



85
86
87
# File 'lib/protocol/redis/methods/hashes.rb', line 85

def hexists(key, field)
	call('HEXISTS', key, field)
end

#hget(key, field) ⇒ Object

Get the value of a hash field. O(1).

Parameters:

  • key (Key)
  • field (String)

See Also:



61
62
63
# File 'lib/protocol/redis/methods/hashes.rb', line 61

def hget(key, field)
	call('HGET', key, field)
end

#hgetall(key) ⇒ Object

Get all the fields and values in a hash. O(N) where N is the size of the hash.

Parameters:

  • key (Key)

See Also:



124
125
126
# File 'lib/protocol/redis/methods/hashes.rb', line 124

def hgetall(key)
	call('HGETALL', key)
end

#hincrby(key, field, increment) ⇒ Object

Increment the integer value of a hash field by the given number. O(1).

Parameters:

  • key (Key)
  • field (String)
  • increment (Integer)

See Also:



94
95
96
# File 'lib/protocol/redis/methods/hashes.rb', line 94

def hincrby(key, field, increment)
	call('HINCRBY', key, field, increment)
end

#hincrbyfloat(key, field, increment) ⇒ Object

Increment the float value of a hash field by the given amount. O(1).

Parameters:

  • key (Key)
  • field (String)
  • increment (Double)

See Also:



103
104
105
# File 'lib/protocol/redis/methods/hashes.rb', line 103

def hincrbyfloat(key, field, increment)
	call('HINCRBYFLOAT', key, field, increment)
end

#hkeys(key) ⇒ Object

Get all the fields in a hash. O(N) where N is the size of the hash.

Parameters:

  • key (Key)

See Also:



110
111
112
# File 'lib/protocol/redis/methods/hashes.rb', line 110

def hkeys(key)
	call('HKEYS', key)
end

#hlen(key) ⇒ Object

Get the number of fields in a hash. O(1).

Parameters:

  • key (Key)

See Also:



30
31
32
# File 'lib/protocol/redis/methods/hashes.rb', line 30

def hlen(key)
	call('HLEN', key)
end

#hmget(key, *fields, &blk) ⇒ Object

Get the values of all the given hash fields. O(N) where N is the number of fields being requested.

Parameters:

  • key (Key)
  • field (String)

See Also:



69
70
71
# File 'lib/protocol/redis/methods/hashes.rb', line 69

def hmget(key, *fields, &blk)
	call('HMGET', key, *fields, &blk)
end

#hmset(key, *attrs) ⇒ Object

Set multiple hash fields to multiple values. O(N) where N is the number of fields being set.

Parameters:

  • key (Key)

See Also:



53
54
55
# File 'lib/protocol/redis/methods/hashes.rb', line 53

def hmset(key, *attrs)
	call('HMSET', key, *attrs)
end

#hset(key, field, value) ⇒ Object

Set the string value of a hash field. O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs.

Parameters:

  • key (Key)

See Also:



37
38
39
# File 'lib/protocol/redis/methods/hashes.rb', line 37

def hset(key, field, value)
	call('HSET', key, field, value)
end

#hsetnx(key, field, value) ⇒ Object

Set the value of a hash field, only if the field does not exist. O(1).

Parameters:

  • key (Key)
  • field (String)
  • value (String)

See Also:



46
47
48
# File 'lib/protocol/redis/methods/hashes.rb', line 46

def hsetnx(key, field, value)
	call('HSETNX', key, field, value)
end

#hvals(key) ⇒ Object

Get all the values in a hash. O(N) where N is the size of the hash.

Parameters:

  • key (Key)

See Also:



117
118
119
# File 'lib/protocol/redis/methods/hashes.rb', line 117

def hvals(key)
	call('HVALS', key)
end