redis.clients.jedis.BinaryJedisCommands Java Examples

The following examples show how to use redis.clients.jedis.BinaryJedisCommands. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisGenericCache.java    From J2Cache with Apache License 2.0 6 votes vote down vote up
@Override
public void setBytes(Map<String,byte[]> bytes) {
    try {
        BinaryJedisCommands cmd = client.get();
        if(cmd instanceof MultiKeyBinaryCommands) {
            byte[][] data = new byte[bytes.size() * 2][];
            int idx = 0;
            for(String key : bytes.keySet()){
                data[idx++] = _key(key);
                data[idx++] = bytes.get(key);
            }
            ((MultiKeyBinaryCommands)cmd).mset(data);
        }
        else
            bytes.forEach((k,v) -> setBytes(k, v));
    } finally {
        client.release();
    }
}
 
Example #2
Source File: RedisGenericCache.java    From J2Cache with Apache License 2.0 6 votes vote down vote up
@Override
public void evict(String...keys) {
    try {
        BinaryJedisCommands cmd = client.get();
        if (cmd instanceof BinaryJedis) {
            byte[][] bytes = Arrays.stream(keys).map(k -> _key(k)).toArray(byte[][]::new);
            ((BinaryJedis)cmd).del(bytes);
        }
        else {
            for (String key : keys)
                cmd.del(_key(key));
        }
    } finally {
        client.release();
    }
}
 
Example #3
Source File: RedisCache.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
public void setBytes(String session_id, Map<String,byte[]> bytes, int expireInSeconds) {
    try {
        Map<byte[], byte[]> data = new HashMap<>();
        bytes.forEach((k,v) -> data.put(k.getBytes(), v));
        byte[] regionBytes = getRegionName(session_id).getBytes();
        BinaryJedisCommands jedis = client.get();
        jedis.hmset(regionBytes, data);
        jedis.expire(regionBytes, expireInSeconds);
    } finally {
        client.release();
    }
}
 
Example #4
Source File: RedisGenericCache.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
@Override
public List<byte[]> getBytes(Collection<String> keys) {
    try {
        BinaryJedisCommands cmd = client.get();
        if(cmd instanceof MultiKeyBinaryCommands) {
            byte[][] bytes = keys.stream().map(k -> _key(k)).toArray(byte[][]::new);
            return ((MultiKeyBinaryCommands)cmd).mget(bytes);
        }
        return keys.stream().map(k -> getBytes(k)).collect(Collectors.toList());
    } finally {
        client.release();
    }
}
 
Example #5
Source File: JedisProviderFactory.java    From azeroth with Apache License 2.0 4 votes vote down vote up
public static BinaryJedisCommands getBinaryJedisCommands(String groupName) {
    return (BinaryJedisCommands) getJedisProvider(groupName).getBinary();
}
 
Example #6
Source File: JedisProviderFactory.java    From jeesuite-libs with Apache License 2.0 4 votes vote down vote up
public static BinaryJedisCommands getBinaryJedisCommands(String groupName) {
	return (BinaryJedisCommands) getJedisProvider(groupName).getBinary();
}