class Redis
def xadd(key, entry, approximate: nil, maxlen: nil, id: '*')
-
(String)
- the entry id
Options Hash:
(**opts)
-
:approximate
(Boolean
) -- whether to add `~` modifier of maxlen or not -
:maxlen
(Integer
) -- max length of entries -
:id
(String
) -- the entry id, default value is `*`, it means auto generation
Parameters:
-
opts
(Hash
) -- several options for `XADD` command -
entry
(Hash
) -- one or multiple field-value pairs -
key
(String
) -- the stream key
Other tags:
- Example: With options -
Example: Without options -
def xadd(key, entry, approximate: nil, maxlen: nil, id: '*') args = [:xadd, key] if maxlen args << "MAXLEN" args << "~" if approximate args << maxlen end args << id args.concat(entry.to_a.flatten) synchronize { |client| client.call(args) } end