1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
/*!
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](https://redis.io/commands/).
Depending on the group of commands, traits will be implemented by [`Client`](crate::client::Client),
[`Pipeline`](crate::client::Pipeline), [`Transaction`](crate::client::Transaction) or some of these structs.
These is the list of existing command traits:
* [`BitmapCommands`]: [Bitmaps](https://redis.io/docs/data-types/bitmaps/) & [Bitfields](https://redis.io/docs/data-types/bitfields/)
* [`BlockingCommands`]: Commands that block the connection until the Redis server
has a new element to send. This trait is implemented only by the [`Client`](crate::client::Client) struct.
* [`ClusterCommands`]: [Redis cluster](https://redis.io/docs/reference/cluster-spec/)
* [`ConnectionCommands`]: Connection management like authentication or RESP version management
* [`GenericCommands`]: Generic commands like deleting, renaming or expiring keys
* [`GeoCommands`]: [Geospatial](https://redis.io/docs/data-types/geospatial/) indices
* [`HashCommands`]: [Hashes](https://redis.io/docs/data-types/hashes/)
* [`HyperLogLogCommands`]: [HyperLogLog](https://redis.io/docs/data-types/hyperloglogs/)
* [`ListCommands`]: [Lists](https://redis.io/docs/data-types/lists/)
* [`PubSubCommands`]: [Pub/Sub](https://redis.io/docs/manual/pubsub/)
* [`ScriptingCommands`]: [Scripts](https://redis.io/docs/manual/programmability/eval-intro/) &
[Functions](https://redis.io/docs/manual/programmability/functions-intro/)
* [`SentinelCommands`]: [Sentinel](https://redis.io/docs/management/sentinel/)
* [`ServerCommands`]: Server management like [Access Control Lists](https://redis.io/docs/management/security/acl/) or monitoring
* [`SetCommands`]: [Sets](https://redis.io/docs/data-types/sets/)
* [`SortedSetCommands`]: [Sorted sets](https://redis.io/docs/data-types/sorted-sets/)
* [`StreamCommands`]: [Streams](https://redis.io/docs/data-types/streams/)
* [`StringCommands`]: [Strings](https://redis.io/docs/data-types/strings/)
* [`TransactionCommands`]: [Transactions](https://redis.io/docs/manual/transactions/)
Redis Stack commands:
* [`BloomCommands`]: [Bloom filters](https://redis.io/docs/stack/bloom/)
* [`CuckooCommands`]: [Cuckoo filters](https://redis.io/docs/stack/bloom/)
* [`CountMinSketchCommands`]: [Count min-sketch](https://redis.io/docs/stack/bloom/)
* [`GraphCommands`]: [RedisGraph](https://redis.io/docs/stack/graph/)
* [`JsonCommands`]: [RedisJson](https://redis.io/docs/stack/json/)
* [`SearchCommands`]: [RedisSearch](https://redis.io/docs/stack/search/)
* [`TDigestCommands`]: [T-Digest](https://redis.io/docs/stack/bloom/)
* [`TimeSeriesCommands`]: [Time Series](https://redis.io/docs/stack/timeseries/)
* [`TopKCommands`]: [Top-K](https://redis.io/docs/stack/bloom/)
# Example
To use a command, simply add the related trait to your `use` declerations
and call the related associated function directly to a client, pipeline, transaction instance.
Commands can be directly awaited or [forgotten](crate::client::ClientPreparedCommand::forget).
```
use rustis::{
client::{Client, ClientPreparedCommand},
commands::{ListCommands, SortedSetCommands, ZAddOptions},
Result,
};
#[cfg_attr(feature = "tokio-runtime", tokio::main)]
#[cfg_attr(feature = "async-std-runtime", async_std::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](https://github.com/redis/redis-doc) with the
following [COPYRIGHT](https://github.com/redis/redis-doc/blob/master/COPYRIGHT).
*/
mod bitmap_commands;
mod blocking_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
mod bloom_commands;
mod cluster_commands;
mod connection_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
mod count_min_sktech_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
mod cuckoo_commands;
#[cfg(test)]
mod debug_commands;
mod generic_commands;
mod geo_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
mod graph_cache;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
mod graph_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
mod graph_value;
mod hash_commands;
mod hyper_log_log_commands;
mod internal_pub_sub_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-json")))]
#[cfg(feature = "redis-json")]
mod json_commands;
mod list_commands;
mod pub_sub_commands;
mod scripting_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-search")))]
#[cfg(feature = "redis-search")]
mod search_commands;
mod sentinel_commands;
mod server_commands;
mod set_commands;
mod sorted_set_commands;
mod stream_commands;
mod string_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
mod t_disgest_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-time-series")))]
#[cfg(feature = "redis-time-series")]
mod time_series_commands;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
mod top_k_commands;
mod transaction_commands;
pub use bitmap_commands::*;
pub use blocking_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
pub use bloom_commands::*;
pub use cluster_commands::*;
pub use connection_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
pub use count_min_sktech_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
pub use cuckoo_commands::*;
#[cfg(test)]
pub use debug_commands::*;
pub use generic_commands::*;
pub use geo_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
pub(crate) use graph_cache::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
pub use graph_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))]
#[cfg(feature = "redis-graph")]
pub use graph_value::*;
pub use hash_commands::*;
pub use hyper_log_log_commands::*;
pub(crate) use internal_pub_sub_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-json")))]
#[cfg(feature = "redis-json")]
pub use json_commands::*;
pub use list_commands::*;
pub use pub_sub_commands::*;
pub use scripting_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-search")))]
#[cfg(feature = "redis-search")]
pub use search_commands::*;
pub use sentinel_commands::*;
pub use server_commands::*;
pub use set_commands::*;
pub use sorted_set_commands::*;
pub use stream_commands::*;
pub use string_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
pub use t_disgest_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-time-series")))]
#[cfg(feature = "redis-time-series")]
pub use time_series_commands::*;
#[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))]
#[cfg(feature = "redis-bloom")]
pub use top_k_commands::*;
pub use transaction_commands::*;