0

I want to migrate data from an old Redis cluster to a new one programmatically, so I did this :

        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).

Is there a way to disable decoding in Redisson ? Or a better way to do this ?

BnJ
  • 1,024
  • 6
  • 18
  • 37
  • I'm 100% sure there's a better way to migrate data than a naive "get 1, put 1" approach. I suggest you dig into the documentation to see if there's more info. – Kayaman Oct 18 '19 at 09:06

1 Answers1

1

Use ByteArrayCodec. Example:

RBucket<Object> bucket = encryptedRedisClient.getBucket(key, ByteArrayCodec.INSTANCE);
bucket.set(value);
bucket.expire(48L, DAYS);
Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71