[英]Migrate data from a Redis cluster to an other with Redisson
I want to migrate data from an old Redis cluster to a new one programmatically, so I did this:我想以编程方式将数据从旧的 Redis 集群迁移到新集群,所以我这样做了:
legacyRedisClient.getKeys()
.getKeys()
.forEach(key -> {
LOGGER.info("Redis Migration : Migrating key {}", key);
Optional.of(legacyRedisClient.getBucket(key))
.filter(RObject::isExists)
.map(RBucket::get)
.ifPresent(value -> {
LOGGER.info("Redis Migration : Storing element with key {}", key);
RBucket<Object> bucket = encryptedRedisClient.getBucket(key);
bucket.set(value);
bucket.expire(48L, DAYS);
});
});
The problem with this, is that I when I do RBucket::get
, Redisson try to decode the value with a class that is not necessarily in the classpath (because that was set by an other microservice).问题在于,当我执行
RBucket::get
时,Redisson 尝试使用不一定在类路径中的 class 解码值(因为它是由其他微服务设置的)。
Is there a way to disable decoding in Redisson?有没有办法在 Redisson 中禁用解码? Or a better way to do this?
或者更好的方法来做到这一点?
Use ByteArrayCodec.使用 ByteArrayCodec。 Example:
例子:
RBucket<Object> bucket = encryptedRedisClient.getBucket(key, ByteArrayCodec.INSTANCE);
bucket.set(value);
bucket.expire(48L, DAYS);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.