-
SSL
-
ACL: better, command support
-
RESP3
-
Client Side Caching: Redesigned
-
Threaded I/O
-
Diskless replication on replicas
-
Cluster support in Redis-benchmark and improved redis-cli cluster support
-
Disque in beta as a module of Redis: start invading the message queue realm
-
Redis Cluster Proxy
-
The RDB can be deleted immediately if it is not needed any more
-
PSYNC2: Optimized replication protocol
-
Timeout setting support is more friendly
-
Faster RDB loading, 20% ~ 30% improvement
-
STRALGO, the new string command, currently only one implementation of LCS (longest common subsequence)
I just released Redis 6.0.1\. Unfortunately there was a bug in Redis 6.0.0 introduced just a few days before the release, that only happens when using the non-default allocator (libc malloc in this case triggers it). Optimization reverted, 6.0.1 released. Sorry for the issue.
This article focuses on the Client Side Caching feature.
Smallnest /RESP3 is a Redis RESP3 protocol parsing library, you can use it to communicate with the underlying Redis, or wrap it to implement a new Version of the Redis client library or Redis Server.
CLIENT TRACKING ON|OFF [REDIRECT client-id] [PREFIX prefix] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]
Copy the code
Invalid message: When the data of a key is changed, redis will send an invalid message to inform the client that the cached data is invalid
-
**REDIRECT**: REDIRECT invalid messages to another client. When communicating with Redis using old RESP2 instead of RESP3, the client does not support handling invalid messages, so we can enable a Pub/Sub client to handle invalid messages. Of course, if the client supports RESP3, it can also forward the invalid message to another client. This CACE we’ll show you at the end.
-
**BCAST**: Start ‘tracking’ using broadcast mode. In this mode, the client needs to set the prefix of track keys, and the invalidation messages of these keys will be broadcast to all participating clients, regardless of whether these clients request/cache these keys. When not in broadcast mode, Redis only tracks keys requested by read-only commands and only reports a failure message once.
-
**PREFIX** : only broadcast mode is applied, registering a key PREFIX. All keys that start with this prefix are modified, and an invalid message is sent. Multiple prefixes can be registered. If the prefix is not set, broadcast mode tracks each key.
-
**OPTIN**: When broadcast mode is not active, normal ** will not **track the keys of read-only commands unless they are called after ‘CLIENT CACHING yes’.
-
**OPTOUT**: When broadcast mode is not active, normal ** tracks the keys of read-only commands unless they are called after ‘CLIENT CACHING off’.
-
**NOLOOP**: Does not send the client’s own modified key.
Test environment setup
make distcleanmakemake testsudo make install
Copy the code
redis-server
Copy the code
Using redis-cli access, default access to native 6379 instance:
redis-cli
Copy the code
BCAST Broadcast Mode (Client Tracking on)
Start the redis – the cli:
Of course, we use Telnet to test, which is convenient to observe the return result of Redis. Just now, redis- CLI is used to update the key value to assist the test. 3 Enable RESP3 protocol:
➜ ~ Telnet localhost 6379Trying ::1... Connected to localhost.Escape character is '^]'. Hello 3%7$6server$5redis$7version$56.0.1......Copy the code
Then try enabling Tracking and reading the value of a:
client tracking on+OKset a 1+OKget a$11
Copy the code
If a redis-cli is used as another client to update a, Telnet should be notified:
127.0.0.1:6379 > set a 2 okCopy the code
Looking at Telnet, it receives an invalid message:
>2$10invalidate*1$1a
Copy the code
Note that it takes the PUSH type (>) in RESP3.
If this uses you to update the value of A using redis-cli, Telnet will no longer receive invalid messages. Unless the Telnet client gets A again, re-tracking a’s value.
Tracking can be cancelled at any time:
client tracking off
Copy the code
Tracking Key for a specific prefix (client tracking on)
The method above will track all keys. If you only want to track specific keys, Redis currently provides a way to do this, which is prefix matching. You can track only keys with specific prefixes. It applies broadcast mode.
Set the prefix and enable tracking using the Telnet client:
hello 3....... client tracking on prefix a bcast+OKclient tracking on prefix user bcast+OKCopy the code
127.0.0.1:6379> set ABC 100ok127.0.0.1:6379 > set user:32432723213 goodok127.0.0.1:6379 > set feed:6532343243432 abcOKCopy the code
>2$10invalidate*1$3abc>2$10invalidate*1$16user:32432723213
Copy the code
. } else if (! strcasecmp(c->argv[2]->ptr,"off")) { disableTracking(c); } else {......Copy the code
Choose to join
client tracking on optin+OKget a$12
Copy the code
client caching yes+OKget a$41000>2$10invalidate*1$1a
Copy the code
client caching yes+OKget b_get a$42000
Copy the code
Choose to leave
client tracking on optout+OKget a$43000>2$10invalidate*1$1a
Copy the code
client caching no+OKget b$13
Copy the code
NOLOOP
client tracking on bcast noloop+OKset a 1+OKclient tracking off+OKclient tracking on bcast+OKset a 1+OK>2$10invalidate*1$1a
Copy the code
REDIRECT
Finally, let’s look at the handling of forwarded messages. This is to comply with RESP2 protocol a processing mode, forwarding the invalid message to another client.
Redis-cli client ID:
127.0.0.1:6379> Client listid=4 addr=127.0.0.1:61017 fd=8 Name = age=33103 IDLE =0 FLAGS =N DB =0 sub=0 Psub =0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 events=r cmd=client user=defaultCopy the code
Telnet to Redis and check client ID:
client id:12
Copy the code
Telnet client enables subscription invalidation messages:
SUBSCRIBE __redis__:invalidate*3$9subscribe$20__redis__:invalidate:1
Copy the code
We can then forward the redis-CLI failure message to the Telnet client:
Client Tracking on bcast Redirect 12127.0.0.1:6379> set a 1000OKCopy the code
*3$7message$20__redis__:invalidate*1$1a
Copy the code