Vercel KV Redis Compatibility
Learn about the Redis commands Vercel KV supports.Vercel KV is available on Hobby and Pro plans
Vercel KV supports commands compatible with the Redis client protocol up to v6.2
.
This documentation provides an overview and examples of the Redis commands supported by our Redis database. For a comprehensive understanding of each command and its options, please refer to the official Redis documentation.
The Redis String data type is used to store and manipulate an array of bytes representing a sequence of characters. Here's an example using the SET
and GET
commands:
> SET user:1 "John Doe"
OK
> GET user:1
"John Doe"
Supported commands:
APPEND
DECR
DECRBY
GET
GETDEL
GETEX
GETRANGE
GETSET
INCR
INCRBY
INCRBYFLOAT
MGET
MSET
MSETNX
PSETEX
SET
SETEX
SETNX
SETRANGE
STRLEN
Redis Bitmaps are used to store and manipulate bit arrays. Bitmaps are not a separate data type, but a set of bit-oriented operations defined on the String type. Here's an example using the SETBIT
and GETBIT
commands:
> SETBIT user:1:flags 0 1
(integer) 0
> GETBIT user:1:flags 0
(integer) 1
Supported commands:
Redis Hash is a data type used to store key-value pairs. Here's an example using the HSET
and HGET
commands:
> HSET user:1 name "John Doe"
(integer) 1
> HGET user:1 name
"John Doe"
Supported commands:
HDEL
HEXISTS
HGET
HGETALL
HINCRBY
HINCRBYFLOAT
HKEYS
HLEN
HMGET
HMSET
HSCAN
HSET
HSETNX
HSTRLEN
HRANDFIELD
HVALS
Redis Lists are ordered collections of strings. Here's an example using the LPUSH
and LRANGE
commands:
> LPUSH fruits "apple"
(integer) 1
> LPUSH fruits "banana"
(integer) 2
> LRANGE fruits 0 -1
1) "banana"
2) "apple"
Supported commands:
BLMOVE
BLPOP
BRPOP
BRPOPLPUSH
LINDEX
LINSERT
LLEN
LMOVE
LPOP
LPOS
LPUSH
LPUSHX
LRANGE
LREM
LSET
LTRIM
RPOP
RPOPLPUSH
RPUSH
RPUSHX
Redis Sets are unordered collections of unique strings. Here's an example using the SADD
and SMEMBERS
commands:
> SADD colors "red"
(integer) 1
> SADD colors "blue"
(integer) 1
> SMEMBERS colors
1) "red"
2) "blue"
Supported commands:
SADD
SCARD
SDIFF
SDIFFSTORE
SINTER
SINTERSTORE
SISMEMBER
SMEMBERS
SMISMEMBER
SMOVE
SPOP
SRANDMEMBER
SREM
SSCAN
SUNION
SUNIONSTORE
Redis Sorted Sets are non-repeating collections of strings ordered by a score. Here's an example using the ZADD
and ZRANGE
commands:
> ZADD scores 10 "player1"
(integer) 1
> ZADD scores 20 "player2"
(integer) 1
> ZRANGE scores 0 -1 WITHSCORES
1) "player1"
2) "10"
3) "player2"
4) "20"
Supported commands:
BZPOPMAX
BZPOPMIN
ZADD
ZCARD
ZCOUNT
ZDIFF
ZDIFFSTORE
ZINCRBY
ZINTER
ZINTERSTORE
ZLEXCOUNT
ZMSCORE
ZPOPMAX
ZPOPMIN
ZRANDMEMBER
ZRANGE
ZRANGESTORE
ZRANGEBYLEX
ZRANGEBYSCORE
ZRANK
ZREM
ZREMRANGEBYLEX
ZREMRANGEBYRANK
ZREMRANGEBYSCORE
ZREVRANGE
ZREVRANGEBYLEX
ZREVRANGEBYSCORE
ZREVRANK
ZSCAN
ZSCORE
ZUNION
ZUNIONSTORE
Redis Geo data type is used to store and manipulate geographical information. Here's an example using the GEOADD
and GEORADIUS
commands:
> GEOADD cities 13.4050 52.5200 "Berlin"
(integer) 1
> GEOADD cities 2.3522 48.8566 "Paris"
(integer) 1
> GEORADIUS cities 13.4050 52.5200 1000 km WITHDIST
1) 1) "Berlin"
2) "0.0000"
2) 1) "Paris"
2) "878.9692"
Supported commands:
GEOADD
GEODIST
GEOHASH
GEOPOS
GEORADIUS
GEORADIUS_RO
GEORADIUSBYMEMBER
GEORADIUSBYMEMBER_RO
GEOSEARCH
GEOSEARCHSTORE
Redis HyperLogLog is a probabilistic data structure used to estimate the cardinality of a set. Here's an example using the PFADD
and PFCOUNT
commands:
> PFADD users "Alice"
(integer) 1
> PFADD users "Bob"
(integer) 1
> PFADD users "Alice"
(integer) 0
> PFCOUNT users
(integer) 2
Supported commands:
Redis Scripting allows the execution of Lua scripts on the server-side. Here's an example using the EVAL
command:
> SET counter 10
OK
> EVAL "return redis.call('INCR', KEYS[1])" 1 counter
(integer) 11
Supported commands:
Pub/Sub is not currently supported through the Vercel KV SDK. Instead, you can use the native Redis client.
Redis Pub/Sub allows sending messages between different clients through channels. Here's an example using the PUBLISH
command:
> PUBLISH news "Breaking news: Redis documentation updated!"
(integer) 5
Supported commands:
Redis Transactions group multiple commands together, ensuring they are executed sequentially and atomically. Here's an example using the MULTI
, INCR
, and EXEC
commands:
> SET balance 100
OK
> MULTI
OK
> INCR balance
QUEUED
> INCR balance
QUEUED
> EXEC
1) (integer) 101
2) (integer) 102
Supported commands:
Redis Generic commands provide general functionality for managing keys. Here's an example using the EXISTS
and DEL
commands:
> SET key1 "value1"
OK
> EXISTS key1
(integer) 1
> DEL key1
(integer) 1
> EXISTS key1
(integer) 0
Supported commands:
COPY
DEL
EXISTS
EXPIRE
EXPIREAT
KEYS
PERSIST
PEXPIRE
PEXPIREAT
PTTL
RANDOMKEY
RENAME
RENAMENX
SCAN
TOUCH
TTL
TYPE
UNLINK
Redis Connection commands are used to manage client connections to the server. Here's an example using the PING
command:
> PING
PONG
Supported commands:
Redis Server commands provide information and control over the Redis server. Here's an example using the DBSIZE
and FLUSHDB
commands:
> SET key1 "value1"
OK
> SET key2 "value2"
OK
> DBSIZE
(integer) 2
> FLUSHDB
OK
> DBSIZE
(integer) 0
Supported commands:
Redis JSON provides native support for storing and manipulating JSON data. Here's an example using the JSON.SET
and JSON.GET
commands:
> JSON.SET user . '{"name": "Alice", "age": 30}'
OK
> JSON.GET user
"{"name":"Alice","age":30}"
Supported commands:
JSON.ARRAPPEND
JSON.ARRINSERT
JSON.ARRINDEX
JSON.ARRLEN
JSON.ARRPOP
JSON.ARRTRIM
JSON.CLEAR
JSON.DEL
JSON.FORGET
JSON.GET
JSON.MGET
JSON.NUMINCRBY
JSON.NUMMULTBY
JSON.OBJKEYS
JSON.OBJLEN
JSON.RESP
JSON.SET
JSON.STRAPPEND
JSON.STRLEN
JSON.TOGGLE
JSON.TYPE
Redis Streams provide a data structure for managing and processing streams of data. Here's an example using the XADD
and XRANGE
commands:
> XADD mystream * sensor-id 1234 temperature 19.8
"1623791288816-0"
> XADD mystream * sensor-id 5678 temperature 21.3
"1623791288816-1"
> XRANGE mystream - +
1) 1) "1623791288816-0"
2) 1) "sensor-id"
2) "1234"
3) "temperature"
4) "19.8"
2) 1) "1623791288816-1"
2) 1) "sensor-id"
2) "5678"
3) "temperature"
4) "21.3"
Supported commands:
Since Vercel KV is a serverless, durable key-value store, you don't need to manage clusters or horizontal scaling.
Was this helpful?