qiujiayu / autoloadcache Goto Github PK
View Code? Open in Web Editor NEWAutoLoadCache 是基于AOP+Annotation等技术实现的高效的缓存管理解决方案,实现缓存与业务逻辑的解耦,并增加异步刷新及“拿来主义机制”,以适应高并发环境下的使用。
License: Apache License 2.0
AutoLoadCache 是基于AOP+Annotation等技术实现的高效的缓存管理解决方案,实现缓存与业务逻辑的解耦,并增加异步刷新及“拿来主义机制”,以适应高并发环境下的使用。
License: Apache License 2.0
有朋友知道github账号为newSue的联系方式吗
对象中缓存的引用类型可存储引用的特定字段 如id否?
我在service中如下调用
@Cache(expire=300, autoload=false, key="")
Caused by: java.lang.IllegalStateException: Serialized class cn.test.sampleData must implement java.io.Serializable
at com.caucho.hessian.io.SerializerFactory.getDefaultSerializer(SerializerFactory.java:372)
at com.caucho.hessian.io.SerializerFactory.loadSerializer(SerializerFactory.java:353)
at com.caucho.hessian.io.SerializerFactory.getSerializer(SerializerFactory.java:253)
at com.caucho.hessian.io.SerializerFactory.getObjectSerializer(SerializerFactory.java:208)
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:462)
at com.caucho.hessian.io.CollectionSerializer.writeObject(CollectionSerializer.java:117)
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:465)
at com.caucho.hessian.io.MapSerializer.writeObject(MapSerializer.java:116)
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:465)
at com.caucho.hessian.io.MapSerializer.writeObject(MapSerializer.java:116)
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:465)
at com.caucho.hessian.io.UnsafeSerializer$ObjectFieldSerializer.serialize(UnsafeSerializer.java:297)
... 11 more
这个页面对spring的依赖太紧了 导致 还需要引入spring的环境
作者可以参考druid的管理页面来调整下这个功能
作者是否可以出个和nutz 框架整合的demo?
我用autoload-cache-spring-boot-starter-master框架里面的test文件夹里面进行调试,原有的数据测试确实没问题,我后来有新增了一些方法进行测试
` @RequestMapping("/queryUsers1")
public List queryUserList1(){
List idList = new ArrayList<>();
idList.add(10);
idList.add(11);
return userService.queryUserList(idList);
}
@RequestMapping("/queryUsers2")
public List<UserDO> queryUserList2(){
List<Integer> idList = new ArrayList<>();
idList.add(10);
idList.add(11);
idList.add(12);
return userService.queryUserList(idList);
}`
@Override public List<UserDO> queryUserList(List<Integer> idList) { return userMapper.getUsers(idList); }
@Cache(expire=300, expireExpression="null==#retVal ? 60: 300", key="'user:getUsers:'") List<UserDO> getUsers(List<Integer> idList);
进行循环插入和循环查询(ps 提交后代码显示不全)
`
select
from user
where id in
#{item}
Hi,
If we are using spring data and mybatis, in our case, we only have an interface definition, no DAO implementation class in our code, is it possible to use AutoLoadCache?
@Cache(
expire =DateEx.SECOND_ONE_HOUR,
autoload = false,
key = "'DanganFamilyMain_decordByPk'",
hfield = "#args[0]",
condition = "#args.length>0",
exCache = {
@ExCache(
expire = DateEx.SECOND_ONE_HOUR,
key = "'DanganFamilyMain_decordByCode'",
hfield = "#retVal.familyCode")
})
public Map<String, Object> findDecordByPk(String rid) {
}
152015462;EL1008E:(pos 8): Property or field 'familyCode' cannot be found on object of type 'java.util.HashMap' - maybe not public? com.jarvis.cache.AbstractCacheManager.getCacheKey(AbstractCacheManager.java:259)[ERROR]http-bio-8080-exec-20 com.jarvis.cache.AbstractCacheManager {} 406098
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Property or field 'familyCode' cannot be found on object of type 'java.util.HashMap' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:211)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:43)
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:338)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:82)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:98)
at com.jarvis.cache.script.SpringELParser.getElValue(SpringELParser.java:79)
at com.jarvis.cache.script.AbstractScriptParser.getDefinedCacheKey(AbstractScriptParser.java:67)
at com.jarvis.cache.AbstractCacheManager.getCacheKey(AbstractCacheManager.java:256)
at com.jarvis.cache.AbstractCacheManager.getCacheKey(AbstractCacheManager.java:318)
at com.jarvis.cache.AbstractCacheManager.writeCache(AbstractCacheManager.java:207)
at com.jarvis.cache.AbstractCacheManager.proceed(AbstractCacheManager.java:124)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.proceed(AspectjAopInterceptor.java:49)
@Cache(expire=600, key="'test'", hfield = "#args[2]+'_'+#args[3]",autoload=true)
public List<String> listIdsByCondition(String tableName, Map<String, Object> condition, Integer page, Integer rows)
@CacheDelete({@CacheDeleteKey(value="'test'")})
public int save(@Param("tableName") String tableName,@Param("fields")Map<String, Object> fields);
上述批量删除缓存的代码在使用本地缓存时(ConcurrentHashMap)不生效,请问是怎么回事呢?
Hi,你好
不知道默认序列化和反序列化是否是使用hessian?现在我的情况是在父类里面定义了一个a field,它有一个annotation org.springframework.data.annotation.Transient ,然后在子类里面重新定义了这个a field 不过没有Transient 这个annotation,问题描述
从数据库读取该对象(子类)时a field是有值的 (从API 返回的JSON上读取到),之后就进入了cache,下次读取就是从cache中读取,此时API 返回的JSON中a field是null。
如果是直接在子类上给a field 加Transient,则不管数据库还是cache都不会返回值
请问是使用方法上有问题,还是Hessian 有bug?谢谢
使用者如对表达式引擎不熟悉的话,对于框架自动生成最终的缓存key值不是很笃定,生成的key值可能不是最优的。
同时也为了方便缓存调试,建议将key中使用表达式引擎后自动生成的key值,通过日志打印出来,方便优化。
RT
是这样 set 的 cache,
@Cache(expire=6000)
public T get(Class t, Long id) {
return (T) dao.unique(t, id);
}
在 update的时候,需要怎么用@CacheDelete
呢
public void update(T t) {
dao.updateById(t);
}
问题描述:在Magic模式下使用FastjsonSerializer返回数据格式不正确,但是切换到hessian正常。
问题版本:autoloadcache:7.0.2 autoload-cache-spring-boot-starter:7.0.2-1
相关代码:
@Cache(expire = 60, expireExpression = "null == #retVal ? 30: 60",
key = "'log-byid-' + #args[0]",
magic = @Magic(key = "'log-byid-' + #retVal.id"))
@Override
public List<BizLogDTO> listDTOByIds(Collection<? extends Serializable> idList) {
return (List) super.listDTOByIds(idList);
}
@Cache(expire = 60, expireExpression = "null == #retVal ? 30: 60", key = "'log-byid-' + #args[0]")
@Override
public BizLogDTO getDTOById(Serializable id) {
return super.getDTOById(id);
}
调用listDTOByIds期望结果:
[{
"id": "6",
"user": "danny",
"operation": "test",
"method": "main",
"time": 12
},
{
"id": "7",
"user": "danny",
"operation": "test",
"method": "main",
"time": 13
}
]
调用listDTOByIds实际结果:
[
[{
"id": "6",
"user": "danny",
"operation": "test",
"method": "main",
"time": 12
}],
[{
"id": "7",
"user": "danny",
"operation": "test",
"method": "main",
"time": 13
}]
]
Magic模式查询中,如果结果数据是 cacheValue + newValue
组成的,那么跟全命中缓存或者全命中数据库的查询结果相比,returnValue
的元素顺序总是不一致的。而且Magic注解的方法内对结果排序是没有意义的,只能在方法调用之后根据传入的参数顺序重新排序一遍↓↓↓
private Object convertToReturnObject(Map<CacheKeyTO, CacheWrapper<Object>> cacheValues, Object newValue) throws Throwable {
if (returnType.isArray()) {
int newValueSize = 0;
Object[] newValues = (Object[]) newValue;
if (null != newValues) {
newValueSize = newValues.length;
}
Object[] res = new Object[cacheValues.size() + newValueSize];
Iterator<Map.Entry<CacheKeyTO, CacheWrapper<Object>>> cacheValuesIt = cacheValues.entrySet().iterator();
int i = 0;
while (cacheValuesIt.hasNext()) {
Map.Entry<CacheKeyTO, CacheWrapper<Object>> item = cacheValuesIt.next();
if (log.isDebugEnabled()) {
log.debug("the data for key:" + item.getKey() + " is from cache, expire :" + item.getValue().getExpire());
}
Object data = item.getValue().getCacheObject();
if (null != data) {
res[i] = data;
i++;
}
}
if (null != newValues) {
for (Object value : newValues) {
if (null != value) {
res[i] = value;
i++;
}
}
}
return res;
} else {
int newValueSize = 0;
Collection<Object> newValues = (Collection<Object>) newValue;
if (null != newValues) {
newValueSize = newValues.size();
}
int resSize = cacheValues.size() + newValueSize;
Collection<Object> res = newCollection(returnType, resSize);
Iterator<Map.Entry<CacheKeyTO, CacheWrapper<Object>>> cacheValuesIt = cacheValues.entrySet().iterator();
while (cacheValuesIt.hasNext()) {
Map.Entry<CacheKeyTO, CacheWrapper<Object>> item = cacheValuesIt.next();
if (log.isDebugEnabled()) {
log.debug("the data for key:" + item.getKey() + " is from cache, expire :" + item.getValue().getExpire());
}
Object data = item.getValue().getCacheObject();
if (null != data) {
res.add(data);
}
}
if (null != newValues) {
for (Object value : newValues) {
if (null != value) {
res.add(value);
}
}
}
return res;
}
}
ERROR com.jarvis.cache.redis.ShardedJedisCacheManager ShardedJedisCacheManager:178 get - MOVED 9300 127.0.0.1:7001
请问是哪里出问题了吗?
@CacheDeleteTransactional
注解的方法内,因为校验等逻辑并没有走到删除缓存的步骤就结束了方法。没有通过抛异常的方式return,而是通过return code来处理,,Set<CacheKeyTO> set
就是空的,然后就有warn
级别的日志。AbstractCacheManager 类中默认使用了 HessianSerializer ,所以即使使用 jdkSerializer 也必需加载 HessianSerializer 相关的包。
建议默认JdkSerializer 或 StringSerializer
Exception in thread "main" java.lang.VerifyError: Expecting a stack map frame
Exception Details:
Location:
com/jarvis/cache/aop/asm/Account$EnhancedByASM.()V @5: aload_0
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: 2ab7 0008 b12a b700 0bb1
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at com.jarvis.cache.aop.asm.SecureAccountGenerator.generateSecureAccount(SecureAccountGenerator.java:28)
at com.jarvis.cache.aop.asm.AccountTest.main(AccountTest.java:11)
我几乎完全按照使用文档配置使用的,但总是报Caused by: com.jarvis.cache.exception.LoadDataTimeOutException
的错误,想问下是哪儿配置的出问题了么
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy60.queryByScheduleId(Unknown Source)
at com.dtsz.scheduletask.service.impl.TriggerServiceImpl.queryByScheduleId(TriggerServiceImpl.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy70.queryByScheduleId(Unknown Source)
at com.dtsz.scheduletask.controller.ScheduleController.queryTriggers(ScheduleController.java:518)
at com.dtsz.scheduletask.controller.ScheduleController$$FastClassBySpringCGLIB$$f9d5bc5d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.dtsz.scheduletask.aspect.SystemLogAspect.doAround(SystemLogAspect.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)
at com.dtsz.scheduletask.controller.ScheduleController$$EnhancerBySpringCGLIB$$209b7631.queryTriggers(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.jarvis.cache.exception.LoadDataTimeOutException: cache for key "schedule:trigger_scheduleId42e93ea3e5c346a285d5a01ee5a3633d" loaded 1 times.
at com.jarvis.cache.DataLoader.doWaitRequest(DataLoader.java:195)
at com.jarvis.cache.DataLoader.loadData(DataLoader.java:116)
at com.jarvis.cache.DataLoader.doWaitRequest(DataLoader.java:193)
at com.jarvis.cache.DataLoader.loadData(DataLoader.java:116)
at com.jarvis.cache.CacheHandler.proceed(CacheHandler.java:194)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.proceed(AspectjAopInterceptor.java:69)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.checkAndProceed(AspectjAopInterceptor.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:97)
at com.jarvis.cache.aop.aspectj.AspectjCacheAopProxyChain.doProxyChain(AspectjCacheAopProxyChain.java:45)
at com.jarvis.cache.DataLoader.getData(DataLoader.java:210)
at com.jarvis.cache.DataLoader.doFirstRequest(DataLoader.java:150)
at com.jarvis.cache.DataLoader.loadData(DataLoader.java:102)
at com.jarvis.cache.CacheHandler.proceed(CacheHandler.java:194)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.proceed(AspectjAopInterceptor.java:69)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.checkAndProceed(AspectjAopInterceptor.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
对于有关联查询的地方,缓存怎么清除?怎么设计比较好?
@Cachedelete({@CacheDeleteKey(value="checkpackageitem-*",condition = "null != #retVal")})
写成XXX*的key,删不掉XXX前缀的所有key,应该怎么做?谢谢
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.56-SNAPSHOT</version>
</dependency>
对缓存进行分类,可以移除同一类缓存,不需要要key属性
支持多级缓存么,如进程级local cache
在我们自己的业务中,需要根据某些操作去清除一批缓存,如果单纯一个key去清除效率又不高,
能否对Cache类进行一个扩展,加入String type() 属性,以便,我们自己能够根据这些type去记录相关的key,并基于type做缓存的清除操作。
你好,请问你把缓存管理页面和缓存管理的Servlet移除掉了吗?
2019-01-09 17:35:19,973 [ERROR] [http-bio-8080-exec-1] com.jarvis.cache.CacheHandler [CacheHandler.java : 265] tried to access class redis.clients.jedis.PipelineBase from class com.jarvis.cache.redis.JedisUtil
java.lang.IllegalAccessError: tried to access class redis.clients.jedis.PipelineBase from class com.jarvis.cache.redis.JedisUtil
at com.jarvis.cache.redis.JedisUtil.executeDelete(JedisUtil.java:86)
at com.jarvis.cache.redis.ShardedJedisCacheManager$ShardedJedisClient.delete(ShardedJedisCacheManager.java:118)
at com.jarvis.cache.redis.AbstractRedisCacheManager.delete(AbstractRedisCacheManager.java:164)
at com.jarvis.cache.CacheHandler.delete(CacheHandler.java:561)
at com.jarvis.cache.CacheHandler.deleteCache(CacheHandler.java:263)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.deleteCache(AspectjAopInterceptor.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:609)
at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:65)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
at suishen.koi.cache.dao.UserDao$$EnhancerBySpringCGLIB$$85762fa7.updateUser()
at suishen.koi.cache.service.UserTestService.updateUser(UserTestService.java:68)
at suishen.koi.web.controller.backend.user.UserController.updateUserById(UserController.java:83)
at suishen.koi.web.controller.backend.user.UserController$$FastClassBySpringCGLIB$$ac38ef2a.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at suishen.koi.common.aop.MethodExecuteInterceptor.invoke(MethodExecuteInterceptor.java:21)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
at suishen.koi.web.controller.backend.user.UserController$$EnhancerBySpringCGLIB$$898e4157.updateUserById()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:302)
at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:170)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at suishen.auth.cas.filter.SuishenCasValidateFilter.doFilter(SuishenCasValidateFilter.java:136)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at suishen.libs.session.filter.GlobalSessionFilter.doFilter(GlobalSessionFilter.java:76)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at suishen.libs.web.filter.DisableUrlSessionFilter.doFilter(DisableUrlSessionFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2019-01-09 17:35:19,985 [ERROR] [http-bio-8080-exec-1] suishen.libs.log.SLogger [AppsExceptionResolver.java : 50] /koi/backend/auth/user/test/5 request error.
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.IllegalAccessError: tried to access class redis.clients.jedis.PipelineBase from class com.jarvis.cache.redis.JedisUtil
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:982)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:302)
at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:170)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at suishen.auth.cas.filter.SuishenCasValidateFilter.doFilter(SuishenCasValidateFilter.java:136)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at suishen.libs.session.filter.GlobalSessionFilter.doFilter(GlobalSessionFilter.java:76)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at suishen.libs.web.filter.DisableUrlSessionFilter.doFilter(DisableUrlSessionFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalAccessError: tried to access class redis.clients.jedis.PipelineBase from class com.jarvis.cache.redis.JedisUtil
at com.jarvis.cache.redis.JedisUtil.executeDelete(JedisUtil.java:86)
at com.jarvis.cache.redis.ShardedJedisCacheManager$ShardedJedisClient.delete(ShardedJedisCacheManager.java:118)
at com.jarvis.cache.redis.AbstractRedisCacheManager.delete(AbstractRedisCacheManager.java:164)
at com.jarvis.cache.CacheHandler.delete(CacheHandler.java:561)
at com.jarvis.cache.CacheHandler.deleteCache(CacheHandler.java:263)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.deleteCache(AspectjAopInterceptor.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:609)
at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:65)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
at suishen.koi.cache.dao.UserDao$$EnhancerBySpringCGLIB$$85762fa7.updateUser()
at suishen.koi.cache.service.UserTestService.updateUser(UserTestService.java:68)
at suishen.koi.web.controller.backend.user.UserController.updateUserById(UserController.java:83)
at suishen.koi.web.controller.backend.user.UserController$$FastClassBySpringCGLIB$$ac38ef2a.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at suishen.koi.common.aop.MethodExecuteInterceptor.invoke(MethodExecuteInterceptor.java:21)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
at suishen.koi.web.controller.backend.user.UserController$$EnhancerBySpringCGLIB$$898e4157.updateUserById()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
... 46 common frames omitted
拿来主交机制,指的是当有多个用户请求同一个数据时,会选举出一个 leader 去数据源加载数据,其它用户则等待其拿到的数据。并由 leader 将数据写入缓存。
数据缓存设置了时间过期
但如果我有个条件 查询多条数据的时候 正好其中的某条(或者某些条)由于过期 在内存中没有了,那以后再有这种查询的时候 如何处理 才能得到符合条件的数据
重新load ?
还是设置过期时间为0?
没有get set 好怪啊
只显示"自动加载队列中无数据! "
版本 4.13
数据确实能够从缓存中获取到,但是管理页面中查看不到数据
<servlet>
<servlet-name>cacheadmin</servlet-name>
<servlet-class>com.jarvis.cache.admin.servlet.AdminServlet</servlet-class>
<init-param>
<!-- 用户名 -->
<param-name>user</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<!-- 密码 -->
<param-name>password</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<param-name>cacheManagerConfig</param-name>
<param-value>com.jarvis.cache.admin.servlet.SpringCacheManagerConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cacheadmin</servlet-name>
<url-pattern>/cacheadmin</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>cacheadmin</servlet-name>
<url-pattern>/sys/cacheadmin</url-pattern>
</servlet-mapping>
map方式 配置
<bean id="autoLoadConfig" class="com.jarvis.cache.to.AutoLoadConfig">
<property name="threadCnt" value="10" />
<property name="maxElement" value="20000" />
<property name="printSlowLog" value="true" />
<property name="slowLoadTime" value="500" />
<property name="sortType" value="1" />
<property name="checkFromCacheBeforeLoad" value="true" />
<property name="autoLoadPeriod" value="50" />
<property name="functions">
<map>
<entry key="isEmpty" value="com.jarvis.cache.CacheUtil" />
</map>
</property>
</bean>
<bean id="fastjsonSerializer" class="com.jarvis.cache.serializer.FastjsonSerializer" />
<bean id="fastjsonCompressorSerializer" class="com.jarvis.cache.serializer.CompressorSerializer">
<constructor-arg ref="fastjsonSerializer" />
<constructor-arg value="1024" /><!-- 超过1024时进行压缩,方便测试所以设置比较小,实际项目中,需要设置大些 -->
</bean>
<bean id="scriptParser" class="com.jarvis.cache.script.SpringELParser" />
<bean id="cacheManager_autoloadCache" class="com.jarvis.cache.map.CachePointCut" init-method="start" destroy-method="destroy">
<constructor-arg ref="autoLoadConfig" />
<constructor-arg ref="fastjsonSerializer" />
<constructor-arg ref="scriptParser" />
<property name="namespace" value="hp" />
<property name="unpersistMaxSize" value="0" />
</bean>
<bean id="cacheInterceptor" class="com.jarvis.cache.aop.aspectj.AspectjAopInterceptor">
<property name="cacheManager" ref="cacheManager_autoloadCache" />
</bean>
同一个VM实例内所有穿透Cache的请求都会调用loadData方法,而loadData方法内部有三处在竞争同一个锁lock,这在高并发场景下很容易导致“锁等待”问题。不知道作者是否有做过性能方面的测试?
ISerializer
接口,使用protobuf序列化。returnType
找到对应的类反序列化。java.util.List
,类型擦除后无法得知泛型的具体类型,无法反序列化。部分配置项,比如AbstractCacheManager.loadData()里的500ms等待时间,AutoLoadRunnable.run() 里的10ms(效率比较高的请求标准 ),这些建议作者抽出来作为可配置项。虽然有“约定优先于配置的说法”,但对于不同的线上系统,对响应时间的要求是不一样的,所以允许用户自由配置是必要的。
Caused by: java.lang.UnsupportedClassVersionError: com/jarvis/cache/annotation/Cache : Unsupported major.minor version 51.0
经常会有这样的场景:执行批量查询操作,先从缓存中批量查询,然后部分key在缓存中,这时会获取到未命中缓存的key,然后再批量去查下db,然后把db返回的数据刷入缓存,请问这种场景,有什么好的解决方案?
key = namespace + key
namespace 当作一个计数器的key ,当要失效这个命名空间下的所有value的时候,直接把namespace 对应的值加1,这样这个命名空间下的所有value就被动都失效了。
例如:
key = "menu"+"userId"
“menu” 对应在缓存对应的value = 1.
key = “1”+ “userId1”;
失效时:
cache.incr("menu") --> menu -->2
key = "2"+"userId1"
我使用jdk8,autoload-cache:4.16,JavaScriptParser,jsel表达式时候出现一个问题
1、在使用@Cache(expire=300, key="retVal.userName", condition="args[0]>0")时候报错:
javax.script.ScriptException: ReferenceError: "retVal" is not defined in at line number 1
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:455) ~[nashorn.jar:na]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:416) ~[nashorn.jar:na]
at jdk.nashorn.api.scripting.NashornScriptEngine.access$300(NashornScriptEngine.java:70) ~[nashorn.jar:na]
at jdk.nashorn.api.scripting.NashornScriptEngine$3.eval(NashornScriptEngine.java:499) ~[nashorn.jar:na]
at javax.script.CompiledScript.eval(CompiledScript.java:92) ~[na:1.8.0_51]
at com.jarvis.cache.script.JavaScriptParser.getElValue(JavaScriptParser.java:87) ~[autoload-cache-4.16.jar:na]
at com.jarvis.cache.script.AbstractScriptParser.getDefinedCacheKey(AbstractScriptParser.java:67) ~[autoload-cache-4.16.jar:na]
at com.jarvis.cache.AbstractCacheManager.getCacheKey(AbstractCacheManager.java:254) [autoload-cache-4.16.jar:na]
at com.jarvis.cache.AbstractCacheManager.getCacheKey(AbstractCacheManager.java:283) [autoload-cache-4.16.jar:na]
at com.jarvis.cache.AbstractCacheManager.proceed(AbstractCacheManager.java:95) [autoload-cache-4.16.jar:na]
at com.jarvis.cache.aop.nutz.AutoLoadCacheAopInterceptor.filter(AutoLoadCacheAopInterceptor.java:42) [autoload-cache-nutz-4.11.jar:na]
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60) [nutz-1.r.57.jar:na]
at flow.core.dao.UserDao$$NUTZAOP.getById(UserDao.java:1) [nutz-1.r.57.jar:na]
2、但是我改成写模式就能正确返回retVal
@Cache(expire=300, key="retVal.userName",opType=CacheOpType.WRITE, condition="args[0]>0")
这种写模式不会报错,但是在读写模式情况下会抛错
AutoLoadHandler 在启动了守护进程时,没有正确处理shutdown方法,原因如下:
class AutoLoadRunnable implements Runnable {
@Override
public void run() {
while (running) {
try {
// 关键是take方法,take方法会阻塞线程,但因为容器已经shutdown了,
// 也不会有数据put进来,导致该守护线程一直阻塞,容器不能正确停止。
// 建议改为 autoLoadQueue.poll(long timeout, TimeUnit unit);
AutoLoadTO tmpTO = autoLoadQueue.take();
if (null != tmpTO) {
loadCache(tmpTO);
Thread.sleep(config.getAutoLoadPeriod());
}
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
}
}
}
... ...
}
Class<?> cls=AopUtil.getTargetClass(invocation.getThis());
Method method=invocation.getMethod();
if(!cls.equals(invocation.getThis().getClass())) {
logger.debug(invocation.getThis().getClass() + "-->" + cls);
return invocation.proceed();
}
请问这段逻辑的作用是什么啊?我在项目中,这段if为真,所以总是没有执行CacheMethodInterceptor里的逻辑,断点跟踪发现我有两个InterceptionAdvice,截图如下:
这个问题是怎么引起的?如何解决?
版本 4.16 ,使用map方式存储
配置信息
@Cache(expire = DateEx.SECOND_ONE_HOUR,
autoload = false, key = "'SysUserServiceImpl_byName'",
hfield = "#retVal.userName", condition = "#args.length>0",
exCache = {@ExCache(
expire = DateEx.SECOND_ONE_HOUR,
key = "'SysUserServiceImpl_bypk'",
hfield = "#retVal.rid")})
public ConsUser findByLoginName(String userName)
目前报错情况下的数据结构,因此会怀疑 ExCache 未成功支持hfield
出错日志
123652056;java.lang.ref.SoftReference cannot be cast to java.util.concurrent.ConcurrentHashMap com.jarvis.cache.AbstractCacheManager.writeCache(AbstractCacheManager.java:227)[ERROR]http-bio-8080-exec-24 com.jarvis.cache.AbstractCacheManager {} 165318
java.lang.ClassCastException: java.lang.ref.SoftReference cannot be cast to java.util.concurrent.ConcurrentHashMap
at com.jarvis.cache.map.CachePointCut.setCache(CachePointCut.java:103)
at com.jarvis.cache.AbstractCacheManager.writeCache(AbstractCacheManager.java:221)
at com.jarvis.cache.AbstractCacheManager.proceed(AbstractCacheManager.java:124)
at com.jarvis.cache.aop.aspectj.AspectjAopInterceptor.proceed(AspectjAopInterceptor.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.