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

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

Introduction

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

Prototype

@Nullable
Object execute(String command, byte[]... args);

Source Link

Document

'Native' or 'raw' execution of the given command along-side the given arguments.

Usage

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

/**
 * 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is,
 * with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or
 * the result./*from   w  w  w .  ja v  a  2s.  c om*/
 * 
 * @param command Command to execute
 * @param args Possible command arguments (may be null)
 * @return execution result.
 */
public static Object execute(String command, byte[]... args) {
    return redisTemplate.execute(new RedisCallback<Object>() {
        @Override
        public Object doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.execute(command, args);
        }
    });
}

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

/**
 * 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is,
 * with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or
 * the result.//from   w  ww  . ja  va  2  s. c om
 * 
 * @param command Command to execute
 * @param args Possible command arguments (may be null)
 * @return execution result.
 */
public Object execute(String command, byte[]... args) {
    return redisTemplate.execute(new RedisCallback<Object>() {
        @Override
        public Object doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.execute(command, args);
        }
    });
}

From source file:org.mitre.mpf.wfm.data.RedisImpl.java

@SuppressWarnings("unchecked")
public synchronized SortedSet<DetectionProcessingError> getDetectionProcessingErrors(long jobId, long mediaId,
        int taskIndex, int actionIndex) {
    final String key = key(JOB, jobId, MEDIA, mediaId, ERRORS, taskIndex, actionIndex);
    int length = (Integer) (redisTemplate.execute(new RedisCallback() {
        @Override/* w w w.  j  a va  2 s  .com*/
        public Object doInRedis(RedisConnection redisConnection) throws DataAccessException {
            return Integer.valueOf(redisConnection.execute("llen", key.getBytes()).toString());
        }
    }));

    if (length == 0) {
        log.debug("No detection processing errors for JOB:{}:MEDIA:{}:{}:{}.", jobId, mediaId, taskIndex,
                actionIndex);
        return new TreeSet<>();
    } else {
        log.debug("{} detection processing errors for JOB:{}:MEDIA:{}:{}:{}.", length, jobId, mediaId,
                taskIndex, actionIndex);
        SortedSet<DetectionProcessingError> errors = new TreeSet<>();
        for (Object errorJson : redisTemplate.boundListOps(key).range(0, length)) {
            try {
                errors.add(jsonUtils.deserialize((byte[]) (errorJson), DetectionProcessingError.class));
            } catch (Exception exception) {
                log.warn("Failed to deserialize '{}'.", errorJson);
            }
        }
        return errors;
    }
}

From source file:org.mitre.mpf.wfm.data.RedisImpl.java

@SuppressWarnings("unchecked")
public synchronized SortedSet<Track> getTracks(long jobId, long mediaId, int taskIndex, int actionIndex) {
    final String key = key(JOB, jobId, MEDIA, mediaId, TRACK, taskIndex, actionIndex);
    int length = (Integer) (redisTemplate.execute(new RedisCallback() {
        @Override//from  w  w w . j  a  v a  2s .  c  o m
        public Object doInRedis(RedisConnection redisConnection) throws DataAccessException {
            return Integer.valueOf(redisConnection.execute("llen", key.getBytes()).toString());
        }
    }));

    if (length == 0) {
        log.debug("No tracks for JOB:{}:MEDIA:{}:{}:{}.", jobId, mediaId, taskIndex, actionIndex);
        return new TreeSet<>();
    } else {
        log.debug("{} tracks for JOB:{}:MEDIA:{}:{}:{}.", length, jobId, mediaId, taskIndex, actionIndex);
        SortedSet<Track> tracks = new TreeSet<>();
        for (Object trackJson : redisTemplate.boundListOps(key).range(0, length)) {
            try {
                tracks.add(jsonUtils.deserialize((byte[]) (trackJson), Track.class));
            } catch (Exception exception) {
                log.warn("Failed to deserialize '{}'.", trackJson);
            }
        }
        return tracks;
    }
}