Generator-jhipster: com.boss.user.service.UserService#clearUserCaches cannot clear the redis cache

Created on 20 Feb 2020  路  8Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

com.boss.user.service.UserService#clearUserCaches cannot clear the redis cache. because user.getLogin() is "admin", but the key in redis hash is "xFCKcom.boss.user.repository.UserRepository_findOneWithAuthoritiesByLogin_admin"

com.boss.user.service.UserService#clearUserCaches
  private void clearUserCaches(User user) {
        Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE)).evict(user.getLogin());
}
the key in redis hash "usersByLogin": 

\xFCKcom.boss.user.repository.UserRepository_findOneWithAuthoritiesByLogin_admin

image

Motivation for or Use Case
Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)

6.7.0

JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory

Browsers and Operating System

  • [ ] Checking this box is mandatory (this is just to show you read everything)

redis

Most helpful comment

cc @Shaolans as he's the one who coded initially the Redis cache

All 8 comments

@TonyLuo : Could you please give some more information on how to reproduce this error. Maybe fill the issue template by including the .yo-rc.json file and any entity configurations you've created. :smile:

@SudharakaP FYI

INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:info
INFO! Options: from-cli: true
Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
[email protected] D:\dev\next\test
`-- [email protected]

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.7.1",
    "applicationType": "monolith",
    "baseName": "test",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "redis",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",        "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1582169100503,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "zh-cn"],
    "blueprints": []
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory


JDL entity definitions


Environment and Tools

java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

git version 2.23.0.windows.1

node: v10.16.3

npm: 6.13.7

yeoman: 3.1.1

yarn: 1.19.0

Docker version 19.03.5, build 633a0ea

docker-compose version 1.24.1, build 4667896b

cc @Shaolans as he's the one who coded initially the Redis cache

I will investigate ASAP !

Hello, sorry for the late reply.
I tried to reproduce your issue, however it seems to be working fine.
When I call clearUserCaches, the usersByLogin is cleared.
Have you updated the generator to the 6.7.X ? Because the method clearUserCaches is different from what I have generated.

public void clearUserCaches(User user) {
        Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE)).evict(user.getLogin());
        if (user.getEmail() != null) {
            Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE)).evict(user.getEmail());
        }
    }

thanks for reply. I did upgrade to 6.7.X.
I just removed following code as our application didn't need it:
if (user.getEmail() != null) { Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE)).evict(user.getEmail()); }

Since your issue does not appear with the app I generated with your .yo-rc.json, can you give me more details on how to reproduce it with minimal changes ?

Closing this as we can't reproduce
Feel free to provide more steps if you're sure about your issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pascalgrimaud picture pascalgrimaud  路  4Comments

RizziCR picture RizziCR  路  3Comments

marcelinobadin picture marcelinobadin  路  3Comments

DanielFran picture DanielFran  路  3Comments

shivroy121 picture shivroy121  路  3Comments