基于 Spring Boot 的注解缓存 ace-cache

码农软件 · 软件分类 · 缓存系统 · 2019-08-29 17:44:16

软件介绍

ace-cache

基于spring boot上的注解缓存,自带轻量级缓存管理页面。 @Cache比spring cache更轻量的缓存,采用fastjon序列化与反序列化,以json串存于缓存之中。 ace-cache可以快速用于日常的spring boot应用或服务之中,快速查看到缓存的状态。

使用手册

缓存配置

1、配置redis数据源,application.yml文件

redis:
    pool:
         maxActive: 300
         maxIdle: 100
         maxWait: 1000
    host: 127.0.0.1
    port: 6379
    password:
    timeout: 2000
    # 服务或应用名
    sysname: ace
    enable: true
    database: 0

缓存开启

2、开启AOP扫描

@ComponentScan({"com.ace.cache"})
@EnableAspectJAutoProxy

缓存使用

3、在Service上进行@Cache注解或@CacheClear注解

注解说明

配置缓存:@Cache

注解参数类型说明
key字符串缓存表达式,动态运算出key
expires整形缓存时长,单位:分钟
desc描述缓存说明
parserClass<? extends ICacheResultParser>缓存返回结果自定义处理类
generatorClass<? extends IKeyGenerator>缓存键值自定义生成类

清除缓存:@CacheClear

注解参数类型说明
pre字符串清除某些前缀key缓存
key字符串清除某个key缓存
keys字符串数组清除某些前缀key缓存
generatorClass<? extends IKeyGenerator>缓存键值自定义生成类

默认key动态表达式说明

表达式举例说明举例
@Cache(key="user:{1}")
public User getUserByAccount(String account)
{1}表示获取第一个参数值
{2}表示获取第二个参数值
&hellip;&hellip;依此类推
若:account = ace,则:key = user:ace
@CacheClear(pre="user{1.account}")
User saveOrUpdate(User user)
{1}表示获取第一个参数值
{1.xx}表示获取第一个参数中的xxx属性
若:account=ace,则:key = user:ace

轻量管理端

访问地址:http://localhost:8080/cache 
管理端批量或前缀清除ace-cache注册的缓存,同时也可以快速预览缓存的数据内容,也可以对缓存的失效时间进行延长。 img

Demo

1、在src/main/test中展开的相关示例代码

CacheTest是核心启动类

service包是缓存调用例子,包含自定义表达式和结果解析、注解的使用

本文地址:https://codercto.com/soft/d/13443.html

Algorithms for Image Processing and Computer Vision

Algorithms for Image Processing and Computer Vision

Parker, J. R. / 2010-12 / 687.00元

A cookbook of algorithms for common image processing applications Thanks to advances in computer hardware and software, algorithms have been developed that support sophisticated image processing with......一起来看看 《Algorithms for Image Processing and Computer Vision》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试