当前位置:网站首页>Sqel easy to use
Sqel easy to use
2022-06-12 03:59:00 【Black humor 595】
sping cache
spEL(Spring Expression Language) Cache definition key And all kinds of condition .
spring Cache utilize AOP The agent ends to implement
spring Provides CacheManage , You can configure the redis cache .
| annotation | effect | Parameter description |
|---|---|---|
| @Cacheable | Configure the method , Cache method results | value: Cache name stay spring Defined in the configuration file key: The cache key , Can be empty or specify SpEL. By default, all parameters of the method are combined condition: Cache conditions , Can be null .SpEL Write back true、fasle ,true Cache when |
| @CachePut | Method configuration , Cache the results after calling the method | The parameters are the same as @Cacheable equally |
| @CacheEvict | Method configuration , Delete cache conditionally | Parametric pain @CAcheable equally allEntries: Whether to empty all cache contents , Default fasle beforeInvocation: Whether to clean up the method before it executes , Default fasle ( Method will not be cleared if it is abnormal ) |
SpEL Introduce
@Cacheable(value = "users" , key = "#user.userName" , condition = "#user.age < 35")
User getUserList();
| name | Location | describe | Example |
|---|---|---|---|
| methodName | root object | Name of the currently called method | #root.methodnaame |
| method | root object | Currently called method | #root.method.name |
| target | root object | Currently called target object instance | #root.target |
| targetClass | root object | The class of the target object being called | #root.targetClass |
| args | root object | The parameter list of the currently called method | #root.args[0] |
| caches | root object | The cache list used by the current method call | #root.caches[0].name |
| Argument | Execution context | The currently called method parameter , method( User u ) adopt #u.name obtain | #u.name |
| result | Execution context | Method returns a value after execution ( After the method is executed, it is judged to be valid ) @CacheVict (beforeInvocation = false) | #result |
// Add cache on interface
public interface CacheService {
@Cacheable(value = "userList" , key = "methodName")
List<User> list();
@Cacheable(value = "user",key = "'user'.concat(#id.toString())")
User findUserById(Long id);
// Here only modify 3 Number
//@CachePut(value="user",key="'user'.concat(#user.name.toString())")
@CachePut(value="user",key="'user'.concat(3)")
User update(User user);
@CacheEvict(value = "user", key = "'user'.concat(#id.toString())")
void remove(Long id);
}
Bottom
边栏推荐
- R language plot visualization: plot visualization grouped violin plot in R with plot
- 无线物联网WiFi模块方案,ESP32-S3芯片技术,助力设备智能化
- PyTorch中的Sequential、ModuleList和ModuleDict用法总结
- Youcans' opencv lesson - 10 Image restoration and reconstruction
- [software tool] [original] tutorial on using VOC dataset class alias batch modification tool
- Detailed explanation of software testing process
- (idea)the file size(2.85M) exceeds configured limit(2.56M).Code insight features are not available问题
- 路灯照明物联网技术方案,ESP32-S3芯片通信应用,智能WiFi远程控制
- 认真工作对自己到底意味着什么?
- PostgreSQL basic introduction and deployment
猜你喜欢

Network tester operation manual renix rack management

Review of technical economy and Enterprise Management Chapter 4

绝对定位使盒子居中显示的三种方式

Convert py file to EXE file

Smart panel WiFi linkage technology, esp32 wireless chip module, Internet of things WiFi communication application
![[MySQL] MySQL installation](/img/f0/2b65b71e79ea0cc0790e4848092374.png)
[MySQL] MySQL installation
![[data recovery in North Asia] data recovery in which the logical volume of the server is changed and the file system is damaged due to system reinstallation](/img/7f/ad628a45bec0ac9a5586d743ca0310.jpg)
[data recovery in North Asia] data recovery in which the logical volume of the server is changed and the file system is damaged due to system reinstallation

微服务概念及介绍

Smart Panel wifi Linkage Technology, esp32 wireless chip module, Internet of Things WiFi Communication Application

怎样拥有心灵的平和?获得一颗全新的心灵
随机推荐
[Yugong series] March 2022 asp Net core Middleware - conditional routing
Database selected 60 interview questions
Batch automated e-mail: Vika Vige table x Tencent Qianfan scene connector has made new moves, and business communication and event marketing only need 3 steps
How to have peace of mind? Get a new heart
The road of global evolution of vivo global mall -- multilingual solution
Message queuing overview
Street lighting IOT technology scheme, esp32-s3 chip communication application, intelligent WiFi remote control
WiFi module scheme of the wireless Internet of things, esp32-s3 chip technology, helps the equipment to be intelligent
Yyds dry inventory MySQL learning - how transactions are isolated
[C language] analysis of variable essence
Esp32c3 remote serial port
How do I extract files from the software?
[untitled]
[Clickhouse column] user initialization of new library role
【mysql】mysql安装
SQL Safe Backup显示器和缩放字体的支持
Brief introduction to 44 official cases of vrtk3.3 (combined with steamvr)
绝对定位使盒子居中显示的三种方式
路灯照明物联网技术方案,ESP32-S3芯片通信应用,智能WiFi远程控制
JSP implementation of bank counter business performance evaluation system