Interface MultiKeyCommands
-
- All Known Implementing Classes:
Jedis
public interface MultiKeyCommands
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Longbitop(BitOP op, String destKey, String... srcKeys)List<String>blpop(int timeout, String... keys)List<String>blpop(String... args)List<String>brpop(int timeout, String... keys)List<String>brpop(String... args)Stringbrpoplpush(String source, String destination, int timeout)Longdel(String... keys)Longexists(String... keys)LonggeoradiusByMemberStore(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)LonggeoradiusStore(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)Set<String>keys(String pattern)Returns all the keys matching the glob-style pattern.List<String>mget(String... keys)Stringmset(String... keysvalues)Longmsetnx(String... keysvalues)longpfcount(String... keys)Stringpfmerge(String destkey, String... sourcekeys)voidpsubscribe(JedisPubSub jedisPubSub, String... patterns)Longpublish(String channel, String message)StringrandomKey()Stringrename(String oldkey, String newkey)Longrenamenx(String oldkey, String newkey)Stringrpoplpush(String srckey, String dstkey)ScanResult<String>scan(String cursor)ScanResult<String>scan(String cursor, ScanParams params)Iterates the set of keys in the currently selected Redis database.Set<String>sdiff(String... keys)Longsdiffstore(String dstkey, String... keys)Set<String>sinter(String... keys)Longsinterstore(String dstkey, String... keys)Longsmove(String srckey, String dstkey, String member)Longsort(String key, String dstkey)Longsort(String key, SortingParams sortingParameters, String dstkey)voidsubscribe(JedisPubSub jedisPubSub, String... channels)Set<String>sunion(String... keys)Longsunionstore(String dstkey, String... keys)Longtouch(String... keys)Longunlink(String... keys)Stringunwatch()Stringwatch(String... keys)List<Map.Entry<String,List<StreamEntry>>>xread(int count, long block, Map.Entry<String,StreamEntryID>... streams)XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]List<Map.Entry<String,List<StreamEntry>>>xreadGroup(String groupname, String consumer, int count, long block, boolean noAck, Map.Entry<String,StreamEntryID>... streams)XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]Longzinterstore(String dstkey, String... sets)Longzinterstore(String dstkey, ZParams params, String... sets)Longzunionstore(String dstkey, String... sets)Longzunionstore(String dstkey, ZParams params, String... sets)
-
-
-
Method Detail
-
keys
Set<String> keys(String pattern)
Returns all the keys matching the glob-style pattern. For example if you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return "foo foobar".
Warning: consider this as a command that should be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use it in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider usingscan(String, ScanParams)or sets.While the time complexity for this operation is O(N), the constant times are fairly low. For example, Redis running on an entry level laptop can scan a 1 million key database in 40 milliseconds.
Glob style patterns examples:
- h?llo will match hello hallo hhllo
- h*llo will match hllo heeeello
- h[ae]llo will match hello and hallo, but not hillo
Use \ to escape special chars if you want to match them verbatim.
Time complexity: O(n) (with n being the number of keys in the DB, and assuming keys and pattern of limited length)
- Parameters:
pattern-- Returns:
- Multi bulk reply
- See Also:
- Redis KEYS documentation
-
sort
Long sort(String key, SortingParams sortingParameters, String dstkey)
-
unwatch
String unwatch()
-
subscribe
void subscribe(JedisPubSub jedisPubSub, String... channels)
-
psubscribe
void psubscribe(JedisPubSub jedisPubSub, String... patterns)
-
randomKey
String randomKey()
-
scan
ScanResult<String> scan(String cursor)
- Parameters:
cursor-- Returns:
- See Also:
scan(String, ScanParams)
-
scan
ScanResult<String> scan(String cursor, ScanParams params)
Iterates the set of keys in the currently selected Redis database.Since this command allows for incremental iteration, returning only a small number of elements per call, it can be used in production without the downside of commands like
keys(String)orJedisCommands.smembers(String))} that may block the server for a long time (even several seconds) when called against big collections of keys or elements.SCAN basic usage
SCAN is a cursor based iterator. This means that at every call of the command, the server returns an updated cursor that the user needs to use as the cursor argument in the next call. An iteration starts when the cursor is set to 0, and terminates when the cursor returned by the server is 0.Scan guarantees
The SCAN command, and the other commands in the SCAN family, are able to provide to the user a set of guarantees associated to full iterations.- A full iteration always retrieves all the elements that were present in the collection from the start to the end of a full iteration. This means that if a given element is inside the collection when an iteration is started, and is still there when an iteration terminates, then at some point SCAN returned it to the user.
- A full iteration never returns any element that was NOT present in the collection from the start to the end of a full iteration. So if an element was removed before the start of an iteration, and is never added back to the collection for all the time an iteration lasts, SCAN ensures that this element will never be returned.
- A given element may be returned multiple times. It is up to the application to handle the case of duplicated elements, for example only using the returned elements in order to perform operations that are safe when re-applied multiple times.
- Elements that were not constantly present in the collection during a full iteration, may be returned or not: it is undefined.
Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the DB.
- Parameters:
cursor- The cursor.params- the scan parameters. For example a glob-style match pattern- Returns:
- the scan result with the results of this iteration and the new position of the cursor
- See Also:
- Redis SCAN documentation
-
pfcount
long pfcount(String... keys)
-
xread
List<Map.Entry<String,List<StreamEntry>>> xread(int count, long block, Map.Entry<String,StreamEntryID>... streams)
XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]- Parameters:
count-block-streams-- Returns:
-
xreadGroup
List<Map.Entry<String,List<StreamEntry>>> xreadGroup(String groupname, String consumer, int count, long block, boolean noAck, Map.Entry<String,StreamEntryID>... streams)
XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]- Parameters:
groupname-consumer-count-block-streams-- Returns:
-
georadiusStore
Long georadiusStore(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
-
georadiusByMemberStore
Long georadiusByMemberStore(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
-
-