Pros and cons of spring-data-redis

spring-data-redis is the integration of redis by spring's cache api. Its naming rules are defined by the rules of spring cache and key management, which further weakens the redis API.

In fact, the functions provided by redis are powerful enough and can be used directly, while supporting flexible sub-libraries.

Spring's cache function is mainly implemented by @Cacheable @CacheEvict @CachePut
@Cacheable is mainly for method configuration, which can cache its results according to the method's request parameters
@CachePut is mainly for method configuration, and can cache its results according to the method's request parameters, Different from @Cacheable, it will trigger the call of the real method every time.
@CachEvict is mainly for method configuration, which can clear the cache according to certain conditions.

By default , Spring uses CacheManagerBean to implement. In fact, there are 3 types: EHCache, Redis , ConcurrentHashMap, the default ConcurrentHashMap is not expired.

The use of Redis also requires manual adjustment of expire, so temporarily use the native jedis and directly call the redis api

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327070463&siteId=291194637