Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 483 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you get a list of streams?

#1
I need to get a list of all streams (keys) in a database but I can't find a command for it.

I've already tried going over all keys and checking their typebut it is too slow/expensive.

I'd like to do something like `XSCAN` and get a list of keys like: `["stream1", "stream2"]`

Reply

#2
There's no such command. Same as there's no way to get a list of other data structures, e.g. LIST, SET.

Instead, you can create an extra SET to record the keys of the streams you created. So that you can scan the SET to get the list of streams.
Reply

#3
If you can have a prefix in the stream names ex: 'MyStream:1', 'MyStream:2'
Then you can use regular scan command with patterns matching MyStream:*

EDIT:
To address OPs concern to not have to use prefix and use SCAN command as is, adding from comments :

You can avoid using a prefix by using namespacing capability provided by redis. You can assign a 'database' (0-15 by default) for streams names. Say you use database 5 for streams, then scan command in database 5 should return the keys in it only. redis.io/commands/select
Reply

#4
As of version 6.0 you can use the TYPE option to ask SCAN to only return objects that match a given type.

SCAN 0 TYPE stream

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through