Java Code Examples for redis.clients.util.SafeEncoder#encodeMany()

The following examples show how to use redis.clients.util.SafeEncoder#encodeMany() . 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: RedisHashMap.java    From azeroth with Apache License 2.0 6 votes vote down vote up
/**
 * 获取多个key的值
 *
 * @param fields
 * @return
 */
public <T> Map<String, T> get(String... fields) {
    try {
        List<byte[]> datas = null;
        Map<String, T> result = new HashMap<>();

        byte[][] encodeFileds = SafeEncoder.encodeMany(fields);
        if (isCluster(groupName)) {
            datas = getBinaryJedisClusterCommands(groupName).hmget(key, encodeFileds);
        } else {
            datas = getBinaryJedisCommands(groupName).hmget(key, encodeFileds);
        }
        for (int i = 0; i < fields.length; i++) {
            result.put(fields[i], (T) valueDerialize(datas.get(i)));
        }
        return result;
    } finally {
        getJedisProvider(groupName).release();
    }

}
 
Example 2
Source File: RedisHashMap.java    From jeesuite-libs with Apache License 2.0 6 votes vote down vote up
/**
 * 获取多个key的值
 * 
 * @param fields
 * @return
 */
public <T> Map<String, T> get(String... fields) {
	try {
		List<byte[]> datas = null;
		Map<String, T> result = new HashMap<>();
		
		byte[][] encodeFileds = SafeEncoder.encodeMany(fields);
		if (isCluster(groupName)) {
			datas = getBinaryJedisClusterCommands(groupName).hmget(keyBytes, encodeFileds);
		} else {
			datas = getBinaryJedisCommands(groupName).hmget(keyBytes, encodeFileds);
		}
		for (int i = 0; i < fields.length; i++) {
			result.put(fields[i], (T)valueDerialize(datas.get(i)));
		}
		return result;
	} finally {
		getJedisProvider(groupName).release();
	}

}
 
Example 3
Source File: RedisBatchCommand.java    From azeroth with Apache License 2.0 5 votes vote down vote up
public static boolean removeObjectsWithGroup(String groupName, String... keys) {
    byte[][] byteKeys = SafeEncoder.encodeMany(keys);
    try {
        if (JedisProviderFactory.isCluster(groupName)) {
            return JedisProviderFactory.getMultiKeyBinaryJedisClusterCommands(groupName)
                    .del(byteKeys) == 1;
        } else {
            return JedisProviderFactory.getMultiKeyBinaryCommands(groupName).del(byteKeys) == 1;
        }
    } finally {
        JedisProviderFactory.getJedisProvider(groupName).release();
    }
}
 
Example 4
Source File: RedisBatchCommand.java    From jeesuite-libs with Apache License 2.0 5 votes vote down vote up
public static boolean removeObjectsWithGroup(String groupName,String...keys){
   	byte[][] byteKeys = SafeEncoder.encodeMany(keys);
       try {			
       	if(JedisProviderFactory.isCluster(groupName)){
       		return JedisProviderFactory.getMultiKeyBinaryJedisClusterCommands(groupName).del(byteKeys) == 1;
       	}else{
       		return JedisProviderFactory.getMultiKeyBinaryCommands(groupName).del(byteKeys) == 1;
       	}
	} finally {
		JedisProviderFactory.getJedisProvider(groupName).release();
	}
}
 
Example 5
Source File: Client.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
@Override
public void exists(final String... keys) {
  final byte[][] bkeys = SafeEncoder.encodeMany(keys);
  exists(bkeys);
}