Redis Accessibility

1. Redis queue

 1.1. Subscribe subscribe ch1 ch2

1.2 publish: publish message publish channel message

 1.3 unsubscribe: unsubscribe channel

1.4 Pattern matching psubscribe ch*

Fuzzy publish, subscribe, unsubscribe, p* <channelName>

1.5 Principle of publish and subscribe

Subscribe to a certain channel or pattern:
client (client):
pubsub_channels, which indicates all channels subscribed by the client;
pubsub_patterns, which indicates all patterns subscribed to by the client;
server (RedisServer):
pubsub_channels, the server All channels in the server and clients subscribed to this channel;
pubsub_patterns, all patterns in the server and clients subscribed to these patterns; 

2. Redis transaction

2.1 redis transaction description

 2.2 redis transaction command

Transaction processing: The value of the watch key changes, causing another thread to fail to modify the key transaction.

 2.3 redis transaction execution

2.3.1 Transaction start ( multi )
In RedisClient, there is an attribute flags, which is used to indicate whether flags=REDIS MULTI is in the transaction.
2.3.2 Command enqueue ( watch {key} )
RedisClient stores commands in the transaction queue (EXEC, DISCARD, WATCH, MULTI except)
2.3.3 Transaction queue
is used to store commands multiCmd *commands
2.3.4 Execution transaction ( exec )
RedisClient sends exec command to the server, RedisServer will traverse the transaction queue, execute the commands in the queue, and finally execute The results are returned to the client at one time. If an error occurs during the enqueuing process of a certain command, redisClient will set flags to REDIS_DIRTY_EXEC, and the EXEC command will fail and return.

2.4 Disadvantages of redis transactions

1. Redis weak transaction
2. The transaction fails with an intermediate syntax error
3. The transaction does not support rollback

3. Redis Monitoring

4. Redis slow query

4.1 Slow query configuration

redis.conf configuration

Redis uses a list to store slow query logs. It can be set temporarily by using the queue method (FIFO)
config set, and it will be invalid after
redis
restarts
. slowlog get [n]

4.2 The underlying data structure

Redis uses lists to store slow query logs, using queues (FIFO)

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_16803227/article/details/132272968
Recommended