class Redis
def xadd(key, entry, opts = {})
-
(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, opts = {}) args = [:xadd, key] args.concat(['MAXLEN', (opts[:approximate] ? '~' : nil), opts[:maxlen]].compact) if opts[:maxlen] args << (opts[:id] || '*') args.concat(entry.to_a.flatten) synchronize { |client| client.call(args) } end