|
| 1 | +# ``RediStack/RedisCommand`` |
| 2 | + |
| 3 | +@Metadata { |
| 4 | + @DocumentationExtension(mergeBehavior: append) |
| 5 | +} |
| 6 | + |
| 7 | +## Command Definitions |
| 8 | + |
| 9 | +Commands that are directly supported by **RediStack** will use the same spelling and naming as found in Redis, |
| 10 | +and are defined as static functions. |
| 11 | + |
| 12 | +For the full list of Redis commands, reference the [Redis Command documentation](https://redis.io/commands). |
| 13 | + |
| 14 | +Some commands are available directly as extensions on ``RedisClient``. |
| 15 | + |
| 16 | +## Custom Commands |
| 17 | + |
| 18 | +If a command is not directly supported by **RediStack**, you can write your own extension on ``RedisCommand`` and use |
| 19 | +the various initializers. |
| 20 | + |
| 21 | +While the `ResultType` of the command is a concrete Swift type, such as an enum, it needs to first be parsed from |
| 22 | +the raw ``RESPValue`` Redis response, which is done with the `mapValueToResult` closure of ``init(keyword:arguments:mapValueToResult:)``. |
| 23 | + |
| 24 | +For types conforming to ``RESPValueConvertible``, this done automatically with the `init(keyword:arguments)` initializer. |
| 25 | + |
| 26 | +## Topics |
| 27 | + |
| 28 | +### Command components |
| 29 | + |
| 30 | +- ``keyword`` |
| 31 | +- ``arguments`` |
| 32 | + |
| 33 | +### Creating a custom command |
| 34 | + |
| 35 | +- ``init(keyword:arguments:mapValueToResult:)`` |
| 36 | + |
| 37 | +### Connection Commands |
| 38 | + |
| 39 | +- ``echo(_:)`` |
| 40 | +- ``ping(with:)`` |
| 41 | +- ``auth(with:)`` |
| 42 | +- ``select(database:)`` |
| 43 | + |
| 44 | +### Hash Commands |
| 45 | + |
| 46 | +- ``hdel(_:from:)-4s5f6`` |
| 47 | +- ``hdel(_:from:)-8zyjq`` |
| 48 | +- ``hexists(_:in:)`` |
| 49 | +- ``hget(_:from:)`` |
| 50 | +- ``hgetall(from:)`` |
| 51 | +- ``hincrby(_:field:in:)`` |
| 52 | +- ``hincrbyfloat(_:field:in:)`` |
| 53 | +- ``hkeys(in:)`` |
| 54 | +- ``hlen(of:)`` |
| 55 | +- ``hmget(_:from:)-az2q`` |
| 56 | +- ``hmget(_:from:)-52q0x`` |
| 57 | +- ``hset(_:to:in:)`` |
| 58 | +- ``hmset(_:in:)`` |
| 59 | +- ``hsetnx(_:to:in:)`` |
| 60 | +- ``hstrlen(of:in:)`` |
| 61 | +- ``hvals(in:)`` |
| 62 | +- ``hscan(_:startingFrom:matching:count:)`` |
| 63 | + |
| 64 | +### Key Commands |
| 65 | + |
| 66 | +- ``del(_:)`` |
| 67 | +- ``exists(_:)-5g9rq`` |
| 68 | +- ``exists(_:)-9qli9`` |
| 69 | +- ``expire(_:after:)`` |
| 70 | +- ``ttl(_:)`` |
| 71 | +- ``pttl(_:)`` |
| 72 | +- ``keys(matching:)`` |
| 73 | +- ``scan(startingFrom:matching:count:)`` |
| 74 | + |
| 75 | +### List Commands |
| 76 | + |
| 77 | +- ``blpop(from:timeout:)-64l4w`` |
| 78 | +- ``blpop(from:timeout:)-5y458`` |
| 79 | +- ``blpop(from:timeout:)-881zh`` |
| 80 | +- ``brpop(from:timeout:)-3uers`` |
| 81 | +- ``brpop(from:timeout:)-235os`` |
| 82 | +- ``brpop(from:timeout:)-906qk`` |
| 83 | +- ``brpoplpush(from:to:timeout:)`` |
| 84 | +- ``lindex(_:from:)`` |
| 85 | +- ``linsert(_:into:before:)`` |
| 86 | +- ``linsert(_:into:after:)`` |
| 87 | +- ``llen(of:)`` |
| 88 | +- ``lpop(from:)`` |
| 89 | +- ``lpush(_:into:)-9wnpn`` |
| 90 | +- ``lpush(_:into:)-6vdyu`` |
| 91 | +- ``lpushx(_:into:)`` |
| 92 | +- ``lrange(from:firstIndex:lastIndex:)`` |
| 93 | +- ``lrange(from:indices:)-947k1`` |
| 94 | +- ``lrange(from:indices:)-555up`` |
| 95 | +- ``lrange(from:fromIndex:)`` |
| 96 | +- ``lrange(from:upToIndex:)`` |
| 97 | +- ``lrange(from:throughIndex:)`` |
| 98 | +- ``lrem(_:from:count:)`` |
| 99 | +- ``lset(index:to:in:)`` |
| 100 | +- ``ltrim(_:before:after:)`` |
| 101 | +- ``ltrim(_:keepingIndices:)-594fr`` |
| 102 | +- ``ltrim(_:keepingIndices:)-9k7s6`` |
| 103 | +- ``ltrim(_:keepingIndices:)-9gvv8`` |
| 104 | +- ``ltrim(_:keepingIndices:)-243g`` |
| 105 | +- ``ltrim(_:keepingIndices:)-3q1zz`` |
| 106 | +- ``rpop(from:)`` |
| 107 | +- ``rpoplpush(from:to:)`` |
| 108 | +- ``rpush(_:into:)-9k27q`` |
| 109 | +- ``rpush(_:into:)-97xay`` |
| 110 | +- ``rpushx(_:into:)`` |
| 111 | + |
| 112 | +### Pub/Sub Commands |
| 113 | + |
| 114 | +- ``publish(_:to:)`` |
| 115 | +- ``pubsubChannels(matching:)`` |
| 116 | +- ``pubsubNumpat()`` |
| 117 | +- ``pubsubNumsub(forChannels:)`` |
| 118 | + |
| 119 | +### Server Commands |
| 120 | + |
| 121 | +- ``swapdb(_:with:)`` |
| 122 | + |
| 123 | +### Set Commands |
| 124 | + |
| 125 | +- ``sadd(_:to:)-2hh4m`` |
| 126 | +- ``sadd(_:to:)-4sxtr`` |
| 127 | +- ``scard(of:)`` |
| 128 | +- ``sdiff(of:)-67ekq`` |
| 129 | +- ``sdiff(of:)-3f66d`` |
| 130 | +- ``sdiffstore(as:sources:)`` |
| 131 | +- ``sinter(of:)-7pqph`` |
| 132 | +- ``sinter(of:)-90a5u`` |
| 133 | +- ``sinterstore(as:sources:)`` |
| 134 | +- ``sismember(_:of:)`` |
| 135 | +- ``smembers(of:)`` |
| 136 | +- ``smove(_:from:to:)`` |
| 137 | +- ``spop(from:max:)`` |
| 138 | +- ``srandmember(from:max:)`` |
| 139 | +- ``srem(_:from:)-2n6ud`` |
| 140 | +- ``srem(_:from:)-21xah`` |
| 141 | +- ``sunion(of:)-2gx4`` |
| 142 | +- ``sunion(of:)-3baqs`` |
| 143 | +- ``sunionstore(as:sources:)`` |
| 144 | +- ``sscan(_:startingFrom:matching:count:)`` |
| 145 | + |
| 146 | +### SortedSet Commands |
| 147 | + |
| 148 | +- ``bzpopmin(from:timeout:)-7ht1z`` |
| 149 | +- ``bzpopmin(from:timeout:)-5lf0y`` |
| 150 | +- ``bzpopmin(from:timeout:)-97ikd`` |
| 151 | +- ``bzpopmax(from:timeout:)-9f01n`` |
| 152 | +- ``bzpopmax(from:timeout:)-6c5lj`` |
| 153 | +- ``bzpopmax(from:timeout:)-79p3g`` |
| 154 | +- ``zadd(_:to:inserting:returning:)-4yuz4`` |
| 155 | +- ``zadd(_:to:inserting:returning:)-1evtg`` |
| 156 | +- ``zadd(_:to:inserting:returning:)-1drwk`` |
| 157 | +- ``zcount(of:withScoresBetween:)`` |
| 158 | +- ``zcount(of:withMaximumScoreOf:)`` |
| 159 | +- ``zcount(of:withMinimumScoreOf:)`` |
| 160 | +- ``zcount(of:withScores:)-6b7ne`` |
| 161 | +- ``zcount(of:withScores:)-6bujq`` |
| 162 | +- ``zcard(of:)`` |
| 163 | +- ``zincrby(_:in:by:)`` |
| 164 | +- ``zinterstore(as:sources:weights:aggregateMethod:)`` |
| 165 | +- ``zlexcount(of:withValuesBetween:)`` |
| 166 | +- ``zlexcount(of:withMinimumValueOf:)`` |
| 167 | +- ``zlexcount(of:withMaximumValueOf:)`` |
| 168 | +- ``zpopmax(from:)`` |
| 169 | +- ``zpopmax(from:max:)`` |
| 170 | +- ``zpopmin(from:)`` |
| 171 | +- ``zpopmin(from:max:)`` |
| 172 | +- ``zrange(from:firstIndex:lastIndex:returning:)`` |
| 173 | +- ``zrange(from:indices:returning:)-95y9o`` |
| 174 | +- ``zrange(from:indices:returning:)-4pd8n`` |
| 175 | +- ``zrange(from:fromIndex:returning:)`` |
| 176 | +- ``zrange(from:throughIndex:returning:)`` |
| 177 | +- ``zrange(from:upToIndex:returning:)`` |
| 178 | +- ``zrangebylex(from:withValuesBetween:limitBy:)`` |
| 179 | +- ``zrangebylex(from:withMaximumValueOf:limitBy:)`` |
| 180 | +- ``zrangebylex(from:withMinimumValueOf:limitBy:)`` |
| 181 | +- ``zrevrangebylex(from:withValuesBetween:limitBy:)`` |
| 182 | +- ``zrevrangebylex(from:withMaximumValueOf:limitBy:)`` |
| 183 | +- ``zrevrangebylex(from:withMinimumValueOf:limitBy:)`` |
| 184 | +- ``zrangebyscore(from:withScoresBetween:limitBy:returning:)`` |
| 185 | +- ``zrangebyscore(from:withScores:limitBy:returning:)-4ukbv`` |
| 186 | +- ``zrangebyscore(from:withScores:limitBy:returning:)-phw`` |
| 187 | +- ``zrangebyscore(from:withMaximumScoreOf:limitBy:returning:)`` |
| 188 | +- ``zrangebyscore(from:withMinimumScoreOf:limitBy:returning:)`` |
| 189 | +- ``zrank(of:in:)`` |
| 190 | +- ``zrem(_:from:)-86osv`` |
| 191 | +- ``zrem(_:from:)-1ey05`` |
| 192 | +- ``zremrangebylex(from:withValuesBetween:)`` |
| 193 | +- ``zremrangebylex(from:withMaximumValueOf:)`` |
| 194 | +- ``zremrangebylex(from:withMinimumValueOf:)`` |
| 195 | +- ``zremrangebyrank(from:firstIndex:lastIndex:)`` |
| 196 | +- ``zremrangebyrank(from:throughIndex:)`` |
| 197 | +- ``zremrangebyrank(from:upToIndex:)`` |
| 198 | +- ``zremrangebyrank(from:fromIndex:)`` |
| 199 | +- ``zremrangebyrank(from:indices:)-2mwa6`` |
| 200 | +- ``zremrangebyrank(from:indices:)-9svqd`` |
| 201 | +- ``zremrangebyscore(from:withScoresBetween:)`` |
| 202 | +- ``zremrangebyscore(from:withScores:)-4lm7a`` |
| 203 | +- ``zremrangebyscore(from:withScores:)-1t3ww`` |
| 204 | +- ``zremrangebyscore(from:withMaximumScoreOf:)`` |
| 205 | +- ``zremrangebyscore(from:withMinimumScoreOf:)`` |
| 206 | +- ``zrevrange(from:firstIndex:lastIndex:returning:)`` |
| 207 | +- ``zrevrange(from:fromIndex:returning:)`` |
| 208 | +- ``zrevrange(from:upToIndex:returning:)`` |
| 209 | +- ``zrevrange(from:throughIndex:returning:)`` |
| 210 | +- ``zrevrange(from:indices:returning:)-3ikhd`` |
| 211 | +- ``zrevrange(from:indices:returning:)-3t0hk`` |
| 212 | +- ``zrevrangebyscore(from:withScoresBetween:limitBy:returning:)`` |
| 213 | +- ``zrevrangebyscore(from:withScores:limitBy:returning:)-2vp67`` |
| 214 | +- ``zrevrangebyscore(from:withScores:limitBy:returning:)-3jdpl`` |
| 215 | +- ``zrevrangebyscore(from:withMaximumScoreOf:limitBy:returning:)`` |
| 216 | +- ``zrevrangebyscore(from:withMinimumScoreOf:limitBy:returning:)`` |
| 217 | +- ``zrevrank(of:in:)`` |
| 218 | +- ``zscore(of:in:)`` |
| 219 | +- ``zunionstore(as:sources:weights:aggregateMethod:)`` |
| 220 | +- ``zscan(_:startingFrom:matching:count:)`` |
| 221 | + |
| 222 | +### String Commands |
| 223 | + |
| 224 | +- ``append(_:to:)`` |
| 225 | +- ``decr(_:)`` |
| 226 | +- ``decrby(_:by:)`` |
| 227 | +- ``get(_:)`` |
| 228 | +- ``incr(_:)`` |
| 229 | +- ``incrby(_:by:)`` |
| 230 | +- ``incrbyfloat(_:by:)`` |
| 231 | +- ``mget(_:)-9m30p`` |
| 232 | +- ``mget(_:)-6kz3i`` |
| 233 | +- ``mset(_:)`` |
| 234 | +- ``msetnx(_:)`` |
| 235 | +- ``psetex(_:to:expirationInMilliseconds:)`` |
| 236 | +- ``set(_:to:)`` |
| 237 | +- ``set(_:to:onCondition:expiration:)`` |
| 238 | +- ``setex(_:to:expirationInSeconds:)`` |
| 239 | +- ``setnx(_:to:)`` |
| 240 | +- ``strln(_:)`` |
0 commit comments