Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

7.3 Redis and Cache


May 14, 2021 JFinal manual



Redis and Cache work together to make it very easy to use the Redis service, the Redis object gets to the Cache object using the use() method, the Cache object provides a rich API for using the Redis service, and here are some examples of how to use it:

public void redisDemo() {
Get the Redis Cache object Cache bbsCache with the name bbs . . . Redis. use ("bbs"); b bsCache.set("key", "value"); bbsCache.get("key");

Get the Redis Cache object Cache with the name news Cache . . . Redis. use ("news"); n ewsCache.set("k", "v"); newsCache.get("k");

The first cache created will become the main Cache, so you can get the bbsCache s Redis by omitting the cacheName parameter. use (); The main cache omitts the cache Name parameter bbsCache.set ("jfinal," "awesome");
}

In the above code, two Cache objects are obtained using the parameters of the use method through "bbs" and "news", which allow you to manipulate their corresponding Redis service side.


Typically, only one RedisPlugin connection is created to the redis server, using Redis.use(.set) (key, value).