Reputation: 739
We are using redis with redisson as a cache database. we want to update expiration time for all fields in a cache, using following code to do so, but getting exception. I think the problem is data deserialisation is failing while loading the data from redis, but we are using same codec to write and read the data. Exception details can be found below
final Config cfg = new Config();
cfg.setCodec(new TypedJsonJacksonCodec(String.class, HashMap.class));
cfg.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(3);
final RedissonClient client = Redisson.create(cfg);
final RMapCache<String, HashMap> cacheMap = client.getMapCache(CACHE_NAME, new TypedJsonJacksonCodec(String.class, HashMap.class));
/**
* cacheMap.put("267041", new ObjectMapper().readValue(ResourceUtils.getFile("classpath:product.json"), HashMap.class));
* cacheMap.put("100305956", new ObjectMapper().readValue(ResourceUtils.getFile("classpath:gridbox.json"), HashMap.class));
*/
System.out.println("##### Start Updating ####");
cacheMap.readAllKeySet().forEach( key -> cacheMap.updateEntryExpiration(key, 30, TimeUnit.DAYS, 0, TimeUnit.MINUTES));
//cacheMap.expireEntries(map.keySet(), Duration.ofMinutes(10), Duration.ZERO);
System.out.println("##### Done Updating #####");
Exception:
Exception in thread "main" org.redisson.client.RedisException: ERR Error running script (call to f_90fcfdb05f5b74bd69bd486619d1a8beeb29bf1b): @user_script:1: user_script:1: bad argument #2 to 'unpack' (data string too short) . channel: [id: 0xe3a03fda, L:/127.0.0.1:61911 - R:127.0.0.1/127.0.0.1:6379] command: (EVAL), promise: java.util.concurrent.CompletableFuture@f3f292c[Not completed, 1 dependents], params: [local s = redis.call('hgetall', KEYS[1]); local maxSize = tonumber(redis.call('hget', KEYS[5], 'max-..., 5, LV:ru:gridboxes, redisson__timeout__set:{LV:ru:gridboxes}, redisson__idle__set:{LV:ru:gridboxes}, redisson__map_cache__last_access__set:{LV:ru:gridboxes}, {LV:ru:gridboxes}:redisson_options, 1720040108012]
am I missing something or is there another way in redisson to update expiration time for fields in a cache.we are using redisson-3.16.8
Upvotes: 0
Views: 83