Aswath Murugan
Aswath Murugan

Reputation: 605

How to create Empty redis stream?

Is possible to create empty stream using spring redis data? Am trying to create rest endpoint to create just stream without data.

Thanks,

Upvotes: 0

Views: 2639

Answers (2)

Mustafa
Mustafa

Reputation: 407

You can XADD with MAXLEN = 0. Like this:

XADD mystream MAXLEN = 0 * key value

Upvotes: 1

for_stack
for_stack

Reputation: 22906

You can use the XGROUP CREATE command with MKSTREAM option, to create an empty stream:

xgroup create s g $ mkstream

If you don't need the group, you can destroy it manually:

xgroup destroy s g

Another solution is to create a stream with XADD command, and then use XDEL key id to remove the newly created entry. In this case, the stream will be kept.

Upvotes: 1

Related Questions