Method: Redis::Commands::Hashes#hrandfield
- Defined in:
- lib/redis/commands/hashes.rb
#hrandfield(key, count = nil, withvalues: false, with_values: withvalues) ⇒ nil, ...
Get one or more random fields from a hash.
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/redis/commands/hashes.rb', line 138 def hrandfield(key, count = nil, withvalues: false, with_values: withvalues) if with_values && count.nil? raise ArgumentError, "count argument must be specified" end args = [:hrandfield, key] args << count if count args << "WITHVALUES" if with_values parser = Pairify if with_values send_command(args, &parser) end |