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, long timeout);

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/* w  ww.ja v a  2  s  . c  o m*/
 * @param option can be {@literal null}. Defaulted to {@link MigrateOption#COPY}.
 * @param timeout timeout
 * @since 1.7
 */
public static void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option, long timeout) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.migrate(key, target, dbIndex, option, timeout);
            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 www. j a  v a 2 s .c o  m
 * @param option can be {@literal null}. Defaulted to {@link MigrateOption#COPY}.
 * @param timeout timeout
 * @since 1.7
 */
public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option, long timeout) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.migrate(key, target, dbIndex, option, timeout);
            return null;
        }
    });
}