Redis keys命令未显示所有键

我将redis用作缓存层,在那儿,我有很多地方在不同的服务和层中使用@Cacheable。

这是示例代码:

buildscript {
    repositories {
        jcenter()
        google() //Add this repo
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
    }
}

allprojects {
    repositories {
        jcenter()
        google() //Add this repo
    }
}

应用程序和缓存工作正常,但是当我使用以下命令获取redis-cli中的所有键时:

@Cacheable(value = "my_detail",key = "'m_detail_'+#entityIdd")
public InstituteDetail getMyDetail(Long entityId) {

    call1();
    call2()
}

@Cacheable(value = "call_1",key = "'call_1'+#entityIdd")
public InstituteDetail getMyDetail1(Long entityId) {

    //some code
}

@Cacheable(value = "call_2",key = "'call_2'+#entityIdd")
public InstituteDetail getMyDetail2(Long entityId) {

    //some code
}

它仅显示呼叫_1和呼叫_2的键。 并且不显示“ my_detail”的密钥。

这很奇怪,没有解决。任何建议,这是怎么了。

lvcha108 回答:Redis keys命令未显示所有键

生成了一个代理类,该类拦截所有请求并以缓存的值进行响应,仅拦截通过代理传入的外部方法调用。这意味着在目标对象内调用同一目标对象的另一个方法,即使调用的方法标记有@Cacheable,也不会在运行时导致实际的缓存拦截。

因此如果该方法调用相同类的其他方法,则不能将'my_detail'值存储在缓存中。

本文链接:https://www.f2er.com/3167456.html

大家都在问