Example usage for org.springframework.data.redis.connection RedisConnection migrate

List of usage examples for org.springframework.data.redis.connection RedisConnection migrate

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection RedisConnection migrate.

Prototype

void migrate(byte[] key, RedisNode target, int dbIndex, @Nullable MigrateOption option);

Source Link

Document

Atomically transfer a key from a source Redis instance to a destination Redis instance.

Usage

From source file:com.zxy.commons.cache.RedisUtils.java

/**
 * @param key must not be {@literal null}.
 * @param target must not be {@literal null}.
 * @param dbIndex dbIndex/*from  w w  w  . ja v  a  2  s  .c  om*/
 * @param option can be {@literal null}. Defaulted to {@link MigrateOption#COPY}.
 * @since 1.7
 */
public static void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.migrate(key, target, dbIndex, option);
            return null;
        }
    });
}

From source file:com.zxy.commons.cache.RedisHelper.java

/**
 * @param key must not be {@literal null}.
 * @param target must not be {@literal null}.
 * @param dbIndex dbIndex/*from   ww  w  . j  ava  2 s. c  o m*/
 * @param option can be {@literal null}. Defaulted to {@link MigrateOption#COPY}.
 * @since 1.7
 */
public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.migrate(key, target, dbIndex, option);
            return null;
        }
    });
}