Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis cache missing cacheName when use custom prefix #35094

Closed
JackyAnn opened this issue Jul 29, 2023 · 4 comments
Closed

redis cache missing cacheName when use custom prefix #35094

JackyAnn opened this issue Jul 29, 2023 · 4 comments
Labels
area/cache area/redis kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@JackyAnn
Copy link

JackyAnn commented Jul 29, 2023

Describe the bug

When using custom cache.redis.prefix

The cacheName set in @CacheResult during key generation is missing
config

cache:
    redis:
      prefix: iot
      key-type: java.lang.String
      value-type: java.lang.String

code

package ltd.doorlink.redis;

import io.quarkus.arc.Unremovable;
import io.quarkus.cache.CacheResult;
import io.quarkus.redis.datasource.RedisDataSource;
import io.quarkus.redis.datasource.value.ValueCommands;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import java.io.Serializable;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Test;

/**
 * @author JackyAnn
 */
@QuarkusTest
public class RedisTest {
  @Inject private Logger logger;
  @Inject private RedisDataSource redisDataSource;


  @Test
  public void setAndGet(){
    RedisCacheTest redisCacheTest = new RedisCacheTest("test");
    ValueCommands<String, RedisCacheTest> commands = redisDataSource.value(RedisCacheTest.class);
    commands.set("test", redisCacheTest);
    logger.info("--->" + commands.get("test"));
    
    
    logger.info("--->" + getRedisStringCacheTest("string"));
    logger.info("--->" + getRedisObjectCacheTest("object"));


  }

  @CacheResult(cacheName = "StringResult")
  public String getRedisStringCacheTest(String key){
    logger.info("--->" + "load data");
    return "redis cache test";
  }

  @CacheResult(cacheName = "ObjectResult")
  public RedisCacheTest getRedisObjectCacheTest(String key){
    logger.info("--->" + "load data");
    return  new RedisCacheTest("test");
  }

  @Unremovable
  public static record RedisCacheTest(String name) implements Serializable {}
}


result cacheName is missing

image

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

Linux fedora 6.2.14-300.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 1 00:55:28 UTC 2023 x86_64 GNU/Linux

Output of java -version

openjdk version "20" 2023-03-21 OpenJDK Runtime Environment (Red_Hat-20.0.0.0.36-1.rolling.fc38) (build 20+36) OpenJDK 64-Bit Server VM (Red_Hat-20.0.0.0.36-1.rolling.fc38) (build 20+36, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.2-rc-2

Additional information

No response

@JackyAnn JackyAnn added the kind/bug Something isn't working label Jul 29, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 29, 2023

/cc @cescoffier (redis), @gsmet (redis), @gwenneg (cache), @machi1990 (redis)

@JackyAnn JackyAnn changed the title redis cache redis cache missing cacheName when use custom profix Jul 29, 2023
@JackyAnn JackyAnn changed the title redis cache missing cacheName when use custom profix redis cache missing cacheName when use custom prefix Jul 29, 2023
@cescoffier
Copy link
Member

The cache name is the name of the cache (so, you need a matching redis cache (named) configuration.
When using the dev mode with the redis dev service, it uses a single redis for everything.

@cescoffier cescoffier closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2023
@cescoffier cescoffier added the triage/invalid This doesn't seem right label Aug 18, 2023
@grottah
Copy link

grottah commented Feb 8, 2024

hi, I also think a prefix is not a replacement of all the caches names, if you have more than one project in the redis cache, will be nice to add a prefix like "project1". ObjectResult. Please this issue need to be addressed.

@cescoffier
Copy link
Member

@grottah please re-open an issue explaining your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cache area/redis kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants