Home > Database > Redis > How to clear the cache in redis

How to clear the cache in redis

WBOY
Release: 2022-08-29 11:56:23
forward
5066 people have browsed it

Recommended learning: Redis video tutorial

How to clear the cache of redis

If your project uses redis La, although the expiration time is set, sometimes to correct the bug, you still need to clear the cache in time to read the database data, so this article explains how to clear the redis cache under Linux.

Text

1. First go to the redis installation directory, go to the src directory, and find redis-cli

2. First, use the account and password to enter the redis server

./redis-cli -h 127.0.0.1 -p 6379 -a 1234

will appear after entering The following interface ip:port>, you can operate

3.

  • flushdb ——> Clear all keys in the current database
  • flushall ——> Clear the data of the entire Redis server (delete all keys in all databases)

End here After the clearing is completed, there is no need to restart. However, everyone should pay attention to whether the cache data of your server is important and whether it can be cleared. You must make sure clearly, otherwise do not clear it easily.

How to clear the redis cache problem

I have developed a project before, using redis, and recently I have been discovering frequent cache problems. Customers are always unable to log in, or the login fails, and then check It was found that it was a cache problem with redis. Clearing the cache of redis is as follows:

mine is the installation-free version of redis

First of all, when we clear the cache , you need to make sure that redis-server.exe is running, otherwise the cache cannot be cleared, then we double-click redis-cli.exe to run:

Then Enter this interface:

We can use the command to clear the cache. Because of the needs of our project, because there is only one project in the server deployed by our project, so I I often use the flushall command to clear the cache. After entering this, press Enter. When you see OK, the cache is successful, as shown in the picture:

Clear the cache here It’s done. There is no need to restart redis. However, it is worth noting that whether the cache data of your server is important and whether it can be cleared entirely, you must make sure before executing the command to clear the cache. If you are not sure whether it can be cleared, it is best to first Only after confirming it will you know, otherwise don’t clear it easily.

The following is the function of the command:

  • flushall: Clear the data of the entire redis server (delete all keys of all databases) .
  • flushdb: Clear all keys in the current database.

Recommended learning: Redis video tutorial

The above is the detailed content of How to clear the cache in redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template