当前位置:网站首页>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
边栏推荐
- Unity脚本出現missing時的解决方法
- SqEL简单上手
- R language plot visualization: plot visualization of basic 2D histogram, custom setting of color of 2D histogram, and histogram visualization of binary distribution (basic 2D histogram)
- 【FPGA+FFT】基于FPGA的FFT频率计设计与实现
- 云原生概述
- 成功解决:WARNING: There was an error checking the latest version of pip.
- Computer configuration suggestions for learning modeling
- Centernet2 practice: take you through the training of custom datasets with centernet2
- What does kotlin collaboration scope and coroutinescope mainscope globalscope viewmodelscope lifecyclescope represent respectively
- DS18B20数字温度计 (一) 电气特性, 供电和接线方式
猜你喜欢

Absolute positioning three ways to center the box

成功解决:WARNING: There was an error checking the latest version of pip.

2.28 (defect filling) data type conversion exception handling part multi threading

mysql/oracle 以唯一时间为分界,小于等于该时间求和,大于该时间求和

SQL Safe Backup显示器和缩放字体的支持

Unity脚本出现missing时的解决方法

Recommended system cleaning tools, cocktail Download

The memory four area model of C language program

How do I make the mouse wheel work in the VB6 ide- How can I make mousewheel work in VB6 IDE?

In 2022, don't you know the difference between arrow function and ordinary function?
随机推荐
spacy中en_core_web_sm安装问题
[C language] encapsulation interface (addition, subtraction, multiplication and division)
2.28 (defect filling) data type conversion exception handling part multi threading
mysql/oracle 以唯一时间为分界,小于等于该时间求和,大于该时间求和
[Yugong series] March 2022 asp Net core Middleware - cross domain
Emperor Wu of Wei knew that he could not correct it, so he stopped offering his words
What is a request response pair called? [repeat] - what is a request response pair called? [duplicate]
R语言plotly可视化:plotly可视化基础二维直方图、自定义设置二维直方图的颜色、二维直方图是二元分布的直方图可视化(Basic 2D Histogram)
How to modify the result name of MySQL query result 1 and result 2
Esp32c3 remote serial port
绝对定位使盒子居中显示的三种方式
Network tester operation manual renix rack management
R language write function: use the write function to write data to the rstudio console, and the write function to write data to a new rstudio window (start a new window)
Double objective learning materials sorting
Street lighting IOT technology scheme, esp32-s3 chip communication application, intelligent WiFi remote control
Unity脚本出現missing時的解决方法
hash function
The road of global evolution of vivo global mall -- multilingual solution
19. Optimized database query of tornado project
根据变换矩阵进行图像拼接