Method: Redis::Commands::Streams#xadd
- Defined in:
- lib/redis/commands/streams.rb
#xadd(key, entry, approximate: nil, maxlen: nil, minid: nil, nomkstream: nil, id: '*') ⇒ String
Add new entry to the stream.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/redis/commands/streams.rb', line 50 def xadd(key, entry, approximate: nil, maxlen: nil, minid: nil, nomkstream: nil, id: '*') args = [:xadd, key] args << 'NOMKSTREAM' if nomkstream if maxlen raise ArgumentError, "can't supply both maxlen and minid" if minid args << "MAXLEN" args << "~" if approximate args << maxlen elsif minid args << "MINID" args << "~" if approximate args << minid end args << id args.concat(entry.flatten) send_command(args) end |