Skip to main content

Module commands

Module commands 

Source
Expand description

Define Redis built-in commands in a set of traits

§Built-in commands

Because Redis offers hundreds of commands, in rustis commands have been split in several traits that gather commands by groups, most of the time, groups describe in Redis official documentation.

Depending on the group of commands, traits will be implemented by Client, Pipeline, Transaction or some of these structs.

These is the list of existing command traits:

§Command coverage

Every command documented on redis.io up to and including Redis 8.8 is implemented, together with its options — including the commands of the bundled modules (RediSearch, RedisJSON, RedisTimeSeries, RedisBloom, vector sets).

Three families are left out on purpose.

Deprecated commands. Their modern replacement is implemented instead, so there is one way to do each thing rather than two:

DeprecatedUse instead
ZREVRANGE, ZRANGEBYSCORE, ZRANGEBYLEX, ZREVRANGEBYSCORE, ZREVRANGEBYLEXzrange with ZRangeOptions
RPOPLPUSH, BRPOPLPUSHlmove, blmove
GEORADIUS, GEORADIUSBYMEMBER, and their _RO variantsgeosearch
HMSEThset
SLAVEOFreplicaof
CLUSTER SLAVEScluster_replicas
FT.ADD, FT.DEL, FT.GET, FT.MGET, FT.DROP, FT.SAFEADD, FT.SYNADDthe hash/JSON document model (ft_create, ft_search)

Server-internal commands, such as PSYNC, SYNC, REPLCONF, RESTORE-ASKING, PFDEBUG, BF.DEBUG, CF.DEBUG or _FT.DEBUG. These belong to the server-to-server or debugging surface; issuing them from a client can corrupt replication or cluster state.

Commands the server declares unstable. The COLLECT reducer of FT.AGGREGATE and FT.HYBRID is documented, but the search module refuses it unless search-enable-unstable-features is set to yes — which means Redis reserves the right to change its grammar and its reply. It is not exposed while that is the case, rather than pin a public API to an interface its own vendor calls provisional.

Note also that a handful of commands appear in COMMAND LIST without being public API — a module’s private surface, recognizable by the absence of any documentation page. Those are not implemented either.

Transactions need no DISCARD: a Transaction is buffered client-side and sent as a single MULTIEXEC batch when execute is called, so abandoning one is simply dropping it — nothing has reached the server yet.

§Example

To use a command, add the related trait to your use declarations and call the related associated function directly on a client, pipeline or transaction instance. prelude carries every trait on the list above, for a program that would otherwise import them one by one.

Commands can be directly awaited or forgotten.

use rustis::{
    client::{Client, ClientPreparedCommand},
    commands::{ListCommands, SortedSetCommands, ZAddOptions},
    Result,
};

#[tokio::main]
async fn main() -> Result<()> {
    let client = Client::connect("127.0.0.1:6379").await?;

    // Send & await ListCommands::lpush command
    let _size = client.lpush("mylist", ["element1", "element2"]).await?;

    // Send & forget SortedSetCommands::zadd command
    let _size = client.zadd(
        "mySortedSet",
        [(1.0, "member1"), (2.0, "member2")],
        ZAddOptions::default()
    ).forget();

    Ok(())
}

§Documentation disclaimer

The commands traits documentation is directly adapated from the official Redis documentation found here with the following COPYRIGHT.

Structs§

AclCatOptions
Options for the acl_cat command
AclDryRunOptions
Options for the acl_dryrun command
AclGenPassOptions
Options for the acl_genpass command
AclLogOptions
Options for the acl_log command
ArGrep
Predicates and options of the argrep command
ArInfoOptions
Options for the arinfo command
ArLastItemsOptions
Options for the arlastitems command
ArrayInfo
Result for the arinfo command
BZpopMinMaxResult
Result for the bzpopmin and bzpopmax commands
BfInfoResult
Result for the bf_info command.
BfInsertOptions
Options for the bf_insert command.
BfReserveOptions
Options for the bf_reserve command.
BfScanDumpResult
Result for the bf_scandump command.
BgsaveOptions
Options for the bgsave command
BitRange
Interval options for the bitcount command
CfInfoResult
Result for the cf_info command.
CfInsertOptions
Options for the cf_insert command.
CfReserveOptions
Options for the cf_reserve command.
CfScanDumpResult
Result for the cf_scandump command.
ClientInfo
Client info results for the client_info & client_list commands.
ClientKillOptions
Options for the client-kill command.
ClientListOptions
Options for the client_list command.
ClientListResult
Result for the client_list command.
ClientTrackingInfo
Result for the client_trackinginfo command.
ClientTrackingOptions
Options for the client_tracking command.
ClusterInfo
Result for the cluster_info command
ClusterLinkInfo
Result for the cluster_links command
ClusterNodeResult
Cluster node result for the cluster_shards command.
ClusterShardResult
Result for the cluster_shards command.
CmsInfoResult
Result for the cms_info command.
CommandArgument
command argument
CommandDoc
Command doc result for the command_docs command
CommandHistogram
Command Histogram for the latency_histogram commands.
CommandInfo
Command info result for the command command.
CommandListOptions
Options for the command_list command.
DatabaseOverhead
Sub-result for the memory_stats command.
EngineStats
sub-result for the function_stats command.
FailOverOptions
Options for the failover command.
FtAggregateOptions
Options for the ft_create command
FtAggregateResult
Result for the ft_aggregate command
FtAttribute
Attribute for the LOAD aggregate option
FtCreateOptions
Options for the ft_create command
FtCursorStats
Cursor stats for the ft_info command
FtFieldSchema
field schema for the ft_create command
FtFlatVectorFieldAttributes
FtGcStats
Garbage collector stats for the ft_info command
FtGroupBy
FtHnswVectorFieldAttributes
FtHybridOptions
Post-processing options for the ft_hybrid command.
FtHybridSearch
Text-search component of the ft_hybrid command.
FtHybridVsim
Vector-similarity component of the ft_hybrid command.
FtIndexAttribute
Index attribute info
FtIndexDefinition
Index definitin for the ft_info command
FtInfoResult
Result for the ft_info command
FtMisspelledTerm
Misspelled term + suggestions for the ft_spellcheck command.
FtReducer
Reducer for the groupby aggregate option
FtScore
A row’s relevance score, as withscores reports it.
FtSearchHighlightOptions
sub-options for the search option summarize
FtSearchOptions
Options for the ft_search command.
FtSearchResult
Result for the ft_search and ft_aggregate commands
FtSearchResultRow
A row in a FtSearchResult
FtSearchSummarizeOptions
sub-options for the search option summarize
FtSortBy
option for the sortby aggregate option
FtSortByProperty
option for the sortby aggregate option
FtSpellCheckOptions
Options for the ft_spellcheck command.
FtSpellCheckResult
Result for the ft_spellcheck command.
FtSugAddOptions
Options for the ft_sugadd command.
FtSugGetOptions
Options for the ft_sugget command.
FtWithCursorOptions
options for the withcursor aggregate option
FunctionInfo
Sub-result for the function_list command.
FunctionListOptions
Options for the function_list command
FunctionStats
Result for the function_stats command.
GeoSearchOptions
Options for the geosearch command
GeoSearchResult
Result of the geosearch command.
GeoSearchStoreOptions
Options for the geosearchstore command
HScanOptions
Options for the hscan command
HScanResult
Result for the hscan command.
HistoricalNote
Sub-result for the command_docs command
HotKeysInfo
Result of one node for the hotkeys_get command.
HotKeysStartOptions
Options for the hotkeys_start command.
IncrExOptions
Options for the increx command
JsonArrIndexOptions
Options for the json_arrindex command
JsonGetOptions
Options for the json_get command
JsonSetOptions
Options for the json_set command
KeySpecification
Key specifications of a command for the command command.
LcsMatch
Part of the result for the lcs command
LcsResult
Result for the lcs command
LibraryInfo
Result for the function_list command.
LolWutOptions
Options for the lolwut command
MemoryStats
Result for the memory_stats command.
MemoryUsageOptions
Options for the memory_usage command
MigrateOptions
Options for the migrate command.
ModuleInfo
Module information result for the module_list command.
ModuleLoadexOptions
Options for the module_loadex command.
ReplicaInfo
Represents a connected replicas to a master
RestoreOptions
Options for the restore command
RunningScript
Sub-result for the function_stats command.
SScanOptions
Options for the sscan command
ScanOptions
Options for the scan command
SentinelInfo
Result for the sentinel_sentinels command.
SentinelMasterInfo
Result for the sentinel_master command.
SentinelReplicaInfo
/// Result for the sentinel_replicas command.
ShutdownOptions
options for the shutdown command.
SlowLogEntry
Result slowlog_get for the command.
SlowLogGetOptions
options for the slowlog_get command.
SortOptions
Options for the sort command
StreamEntry
Result for the xrange and other associated commands.
TDigestInfoResult
Result for the tdigest_info command.
TDigestMergeOptions
Options for the tdigest_merge command.
TopKInfoResult
Result for the topk_info command.
TopKListWithCountResult
TsAddOptions
Options for the ts_add command.
TsCompactionRule
information about the compaction rules of a time series collection, in the context of the ts_info command.
TsCreateOptions
Options for the ts_add command.
TsCreateRuleOptions
Options for the ts_createrule command.
TsGetOptions
Options for the ts_get command.
TsGetResult
Result for the ts_get command: the last sample of a time series, or nothing when the series is empty.
TsGroupByOptions
Options for the ts_mrange command.
TsIncrByDecrByOptions
Options for the ts_incrby and ts_decrby commands.
TsInfoChunkResult
Additional debug result for the ts_info command.
TsInfoResult
Result for the ts_info command.
TsMGetOptions
Options for the ts_mget command.
TsMRangeOptions
Options for the ts_mrange and ts_mrevrange commands.
TsRangeOptions
Options for the ts_range and ts_revrange commands.
TsRangeSample
Result for the ts_mrange and ts_mrevrange commands.
TsSample
Result for the ts_mget command.
VAddOptions
Options for the vadd command.
VInfoResult
Result for the vinfo command.
VSimOptions
Options for the vsim command.
XAddOptions
Stream Add options for the xadd command.
XAutoClaimOptions
Options for the xautoclaim command
XAutoClaimResult
Result for the xautoclaim command.
XCfgSetOptions
Options for the xcfgset command.
XClaimOptions
Options for the xclaim command
XConsumerInfo
Result entry for the xinfo_consumers command.
XGroupCreateOptions
Options for the xgroup_create command
XGroupInfo
Result entry for the xinfo_groups command.
XInfoStreamOptions
Options for the xinfo_stream command
XNackOptions
Options for the xnack command.
XPendingConsumer
Customer info result for the xpending command
XPendingMessageResult
Message result for the xpending_with_options command
XPendingOptions
Options for the xpending_with_options command
XPendingResult
Result for the xpending command
XReadGroupOptions
Options for the xreadgroup command
XReadOptions
Options for the xread command
XSetIdOptions
Options for the xsetid command.
XStreamInfo
Stream info returned by the xinfo_stream command.
XTrimOptions
Stream Trim options for the xadd and xtrim commands
ZAddOptions
Options for the zadd command.
ZRangeOptions
Options for the zrange and zrangestore commands
ZScanOptions
Options for the zscan command
ZScanResult
Result for the zscan command.

Enums§

ArGrepPredicate
A textual predicate of the argrep command
ArOperation
Aggregate operation of the arop command
ArgumentFlag
Flag for a command argument
BeginSearch
The BeginSearch value of a specification informs the client of the extraction’s beginning
BfInfoParameter
Optional parameter for the bf_info command.
BitFieldOverflow
Option for the BitFieldSubCommand sub-command.
BitFieldSubCommand
Sub-command for the bitfield command
BitOperation
Bit operation for the bitop command.
BitUnit
Unit of a range, bit or byte
ClientCachingMode
Client caching mode for the client_caching command.
ClientInfoAttribute
ClientPauseMode
Mode options for the client_pause command.
ClientReplyMode
Mode options for the client_reply command.
ClientTrackingStatus
Status options for the client_tracking command.
ClientType
Client type options for the client_list command.
ClientUnblockMode
Mode options for the client_unblock command.
ClusterBumpEpochResult
Result for the cluster_bumpepoch command
ClusterFailoverOption
Options for the cluster_failover command
ClusterHealthStatus
Cluster health status for the cluster_shards command.
ClusterLinkDirection
This link is established by the local node to the peer, or accepted by the local node from the peer.
ClusterMigrationTarget
Task selector for the cluster_migration_cancel and cluster_migration_status commands.
ClusterResetType
Type of cluster reset
ClusterSetSlotSubCommand
Subcommand for the cluster_setslot command.
ClusterSlotStatMetric
Metric to sort by in ClusterSlotStatsFilter::OrderBy.
ClusterSlotStatsFilter
Slot selection for the cluster_slot_stats command.
ClusterState
Cluster state used in the cluster_state field of ClusterInfo
CommandArgumentType
An argument must have one of the following types:
CommandDocFlag
Command documenation flag
CommandTip
Get additional information about a command
ConsumerGroupOptions
Consumer group options for the xadd command.
DelexCondition
Condition option for the delex command.
ExpireOption
Options for the expire and hexpire commands
FindKeys
The FindKeys value of a key specification tells the client how to continue the search for key names.
FlushingMode
Database flushing mode
FtAttributeValue
The value of one attribute of a FtSearchResultRow.
FtFieldType
Field type used to declare an index schema for the ft_create command
FtGeoShapeCoordSystem
Coordinate system of a Geoshape field
FtHybridCombine
Fusion method for the COMBINE clause of ft_hybrid.
FtHybridFormat
Result serialization format for FtHybridOptions.
FtHybridLoad
LOAD selection for FtHybridOptions.
FtHybridVectorQuery
Vector query type for the FtHybridVsim clause.
FtIndexAll
INDEXALL setting of the ft_create command.
FtIndexDataType
Redis Data type of an index defined in FtCreateOptions struct
FtLanguage
Redis search supported languages See. Supported Languages
FtPhoneticMatcher
Phonetic algorithm and language used for the FtFieldSchema::phonetic associated function
FtScorerOptions
options for the scorer aggregate option
FtTermType
Term type for the option terms
FtVectorDistanceMetric
FtVectorFieldAlgorithm
FtVectorType
FunctionRestorePolicy
Policy option for the function_restore command.
GeoAddCondition
Condition for the geoadd command
GeoSearchBy
The query’s shape is provided by one of these mandatory options:
GeoSearchFrom
The query’s center point is provided by one of these mandatory options:
GeoSearchOrder
Matching items are returned unsorted by default. To sort them, use one of the following two options:
GeoUnit
Distance Unit
GetExOptions
Options for the getex and the hgetex commands
HSetExCondition
Condition option for the hsetex command
HotKeysMetric
Metric tracked by the hotkeys_start command.
InfoSection
Section for the info command.
JsonFpType
Storage type of a floating-point homogeneous array, for the fpha option of the json_set command.
JsonGetFormat
Reply format for the json_get command.
KeyType
Result for the type command
LInsertWhere
Where option for the linsert command.
LMoveWhere
Where option for the lmove command.
LatencyHistoryEvent
Latency history event for the latency_graph & latency_history commands.
MigrateResult
Result for the migrate command
QuantizationOptions
Quantization options for vadd command.
ReplicaOfOptions
options for the replicaof command.
ReplicationState
The state of the replication from the point of view of the master,
RequestPolicy
This tip can help clients determine the shards to send the command in clustering mode.
ResponsePolicy
This tip can help clients determine the aggregate they need to compute from the replies of multiple shards in a cluster.
RoleResult
Result for the role command.
ScriptDebugMode
Options for the script_debug command.
SentinelSimulateFailureMode
Different crash simulation scenario modes for the sentinel_simulate_failure command
SetCondition
Condition option for the set_with_options command
SetExpiration
Expiration option for the set_with_options and hsetex commands
SortOrder
Order option of the sort command
StreamEntryDeletionPolicy
Controls how consumer-group references are handled when stream entries are removed. Shared by every entry-removing command since Redis 8.2 — here the trimming clause of xadd, xtrim, xdelex and xackdel.
TsAggregationType
Aggregation type for the ts_createrule and ts_mrange commands.
TsBucketTimestamp
Which point of an aggregation bucket its reported timestamp is, for the BUCKETTIMESTAMP option of the range commands.
TsDuplicatePolicy
Policy for handling samples with identical timestamps
TsEncoding
specifies the series samples encoding format.
TsTimestamp
Timeseries Timestamp
VectorOrElement
Argument of the vsim command
XNackMode
How xnack adjusts the delivery counter of the released messages.
XTrimOperator
Stream Trim operator for the xadd and xtrim commands
ZAddComparison
Comparison option for the zadd command
ZAddCondition
Condition option for the zadd command
ZAggregate
Option that specify how results of an union or intersection are aggregated
ZRangeSortBy
sort by option of the zrange command
ZWhere
Where option of the zmpop command

Traits§

ArrayCommands
A group of Redis commands related to Arrays
BitmapCommands
A group of Redis commands related to Bitmaps & Bitfields
BlockingCommands
A group of blocking commands
BloomCommands
A group of Redis commands related to Bloom filters
ClusterCommands
A group of Redis commands related to Cluster Management
ConnectionCommands
A group of Redis commands related to connection management
CountMinSketchCommands
A group of Redis commands related to Count-min Sketch
CuckooCommands
A group of Redis commands related to Cuckoo filters
GenericCommands
A group of generic Redis commands
GeoCommands
A group of Redis commands related to Geospatial indices
HashCommands
A group of Redis commands related to Hashes
HyperLogLogCommands
A group of Redis commands related to HyperLogLog
JsonCommands
A group of Redis commands related to RedisJson
ListCommands
A group of Redis commands related to Lists
PubSubCommands
A group of Redis commands related to Pub/Sub
ScriptingCommands
A group of Redis commands related to Scripting and Functions
SearchCommands
A group of Redis commands related to RedisSearch
SentinelCommands
A group of Redis commands related to Sentinel
ServerCommands
A group of Redis commands related to Server Management
SetCommands
A group of Redis commands related to Sets
SortedSetCommands
A group of Redis commands related to Sorted Sets
StreamCommands
A group of Redis commands related to Streams
StringCommands
A group of Redis commands related to Strings
TDigestCommands
A group of Redis commands related to T-Digest
TimeSeriesCommands
A group of Redis commands related to Time Series
TopKCommands
A group of Redis commands related to Top-K
TransactionCommands
A group of Redis commands related to Transactions
VectorSetCommands
A group of Redis commands related to Vector Sets

Type Aliases§

ZMPopResult
Result for zmpop the command.