Java Code Examples for redis.clients.jedis.Jedis#hexists()
The following examples show how to use
redis.clients.jedis.Jedis#hexists() .
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: RedisClient.java From apollo with GNU General Public License v2.0 | 6 votes |
public boolean hExists(String key, String field) throws Exception { Jedis jedis = null; try { jedis = this.jedisPool.getResource(); boolean ret = jedis.hexists(SafeEncoder.encode(key), SafeEncoder.encode(field)); logger.info("hexists key:" + key + ", field:" + field); return ret; } catch (Exception e) { logger.error(e.getMessage(), e); this.jedisPool.returnBrokenResource(jedis); throw e; } finally { if (jedis != null) { this.jedisPool.returnResource(jedis); } } }
Example 2
Source File: JedisClientPool.java From paas with Apache License 2.0 | 5 votes |
@Override public Boolean hexists(String key, String field) { Jedis jedis = jedisPool.getResource(); Boolean result = jedis.hexists(key, field); jedis.close(); return result; }
Example 3
Source File: PasswordDB.java From VileBot with MIT License | 5 votes |
/** * Add or modify a user's password * * @param username unique user name * @param password the user's password (will be hashed) * @return true iff a new element was inserted */ public static boolean setUserPassword( String username, String password ) { Jedis jedis = pool.getResource(); try { boolean newUser; Transaction trans; do { // Can't use intermediate results of a Redis transaction in that transaction, so watch the keys and do // the query before opening the transaction. The transaction will fail on exec() call if the keys // changed. jedis.watch( keyOfPassHash, keyOfPassSaltsHash ); boolean exists = jedis.hexists( keyOfPassHash, username ); trans = jedis.multi(); // Create a salt as well as the new password entry if the user is new if ( !exists ) { newUser = true; String salt = generateSalt(); trans.hset( keyOfPassSaltsHash, username, salt ); String hash = hash( password, salt ); trans.hset( keyOfPassHash, username, hash ); } else newUser = false; } while ( trans.exec() == null ); return newUser; } finally { pool.returnResource( jedis ); } }
Example 4
Source File: JedisUtils.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * 判断Map缓存中的Key是否存在 * @param key 键 * @param value 值 * @return */ public static boolean mapObjectExists(String key, String mapKey) { boolean result = false; Jedis jedis = null; try { jedis = getResource(); result = jedis.hexists(getBytesKey(key), getBytesKey(mapKey)); logger.debug("mapObjectExists {} {}", key, mapKey); } catch (Exception e) { logger.warn("mapObjectExists {} {}", key, mapKey, e); } finally { returnResource(jedis); } return result; }
Example 5
Source File: JedisUtils.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * 判断Map缓存中的Key是否存在 * @param key 键 * @param value 值 * @return */ public static boolean mapExists(String key, String mapKey) { boolean result = false; Jedis jedis = null; try { jedis = getResource(); result = jedis.hexists(key, mapKey); logger.debug("mapExists {} {}", key, mapKey); } catch (Exception e) { logger.warn("mapExists {} {}", key, mapKey, e); } finally { returnResource(jedis); } return result; }
Example 6
Source File: RedisServiceImpl.java From ace-cache with Apache License 2.0 | 5 votes |
@Override public Boolean hexists(String key, String field) { Jedis jedis = null; Boolean res = false; try { jedis = pool.getResource(); res = jedis.hexists(key, field); } catch (Exception e) { LOGGER.error(e.getMessage()); } finally { returnResource(pool, jedis); } return res; }
Example 7
Source File: JedisUtils.java From easyweb with Apache License 2.0 | 5 votes |
/** * 判断Map缓存中的Key是否存在 * @param key 键 * @return */ public static boolean mapObjectExists(String key, String mapKey) { boolean result = false; Jedis jedis = null; try { jedis = getResource(); result = jedis.hexists(getBytesKey(key), getBytesKey(mapKey)); logger.debug("mapObjectExists {} {}", key, mapKey); } catch (Exception e) { logger.warn("mapObjectExists {} {}", key, mapKey, e); } finally { returnResource(jedis); } return result; }
Example 8
Source File: JedisUtils.java From easyweb with Apache License 2.0 | 5 votes |
/** * 判断Map缓存中的Key是否存在 * @param key 键 * @return */ public static boolean mapExists(String key, String mapKey) { boolean result = false; Jedis jedis = null; try { jedis = getResource(); result = jedis.hexists(key, mapKey); logger.debug("mapExists {} {}", key, mapKey); } catch (Exception e) { logger.warn("mapExists {} {}", key, mapKey, e); } finally { returnResource(jedis); } return result; }
Example 9
Source File: JedisClientPool.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
@Override public Boolean hexists(String key, String field) { Jedis jedis = jedisPool.getResource(); Boolean result = jedis.hexists(key, field); jedis.close(); return result; }
Example 10
Source File: RedisClient.java From Mykit with Apache License 2.0 | 5 votes |
public boolean hexists(String key, String field) { Jedis client = jedisPool.getResource(); try { return client.hexists(key, field); } finally { // 向连接池“归还”资源 jedisPool.returnResourceObject(client); } }
Example 11
Source File: JedisClientPool.java From blog-sample with Apache License 2.0 | 5 votes |
@Override public Boolean hexists(String key, String field) { Jedis jedis = jedisPool.getResource(); Boolean result = jedis.hexists(key, field); jedis.close(); return result; }
Example 12
Source File: JedisClientPool.java From express-ssm with Apache License 2.0 | 5 votes |
@Override public Boolean hexists(String key, String field) { Jedis jedis = jedisPool.getResource(); Boolean result = jedis.hexists(key, field); jedis.close(); return result; }
Example 13
Source File: JedisUtil.java From scaffold-cloud with MIT License | 5 votes |
/** * 判断Map缓存中的Key是否存在 * * @param key 键 * @param mapKey * @return */ public static boolean mapObjectExists(String key, String mapKey) { boolean result = false; Jedis jedis = null; try { jedis = getResource(); result = jedis.hexists(getBytesKey(key), getBytesKey(mapKey)); } catch (Exception e) { logger.warn("mapObjectExists {} {}", key, mapKey, e); } finally { close(jedis); } return result; }
Example 14
Source File: JedisUtil.java From scaffold-cloud with MIT License | 5 votes |
/** * 判断Map缓存中的Key是否存在 * * @param key 键 * @param mapKey * @return */ public static boolean mapExists(String key, String mapKey) { boolean result = false; Jedis jedis = null; try { jedis = getResource(); result = jedis.hexists(key, mapKey); } catch (Exception e) { logger.warn("mapExists {} {}", key, mapKey, e); } finally { close(jedis); } return result; }
Example 15
Source File: JedisUtils.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
/** * <p> * 通过key和field判断是否有指定的value存在 * </p> * * @param key * @param field * @return */ public Boolean hexists(String key, String field) { Jedis jedis = null; Boolean res = false; try { jedis = jedisPool.getResource(); res = jedis.hexists(key, field); } catch (Exception e) { log.error(e.getMessage()); } finally { returnResource(jedisPool, jedis); } return res; }
Example 16
Source File: MapCacheOperate.java From xian with Apache License 2.0 | 4 votes |
public static boolean exists(Jedis jedis, String key, String field) { return jedis.hexists(key, field); }
Example 17
Source File: DefaultRedis.java From craft-atom with MIT License | 4 votes |
private Boolean hexists0(Jedis j, String key, String field) { return j.hexists(key, field); }
Example 18
Source File: JedisUtil.java From Project with Apache License 2.0 | 3 votes |
/** * 测试hash中指定的存储是否存在 * * @param key * @param fieid 存储的名字 * @return 1存在,0不存在 */ public boolean hexists(String key, String fieid) { Jedis sjedis = getJedis(); boolean s = sjedis.hexists(key, fieid); sjedis.close(); return s; }
Example 19
Source File: JedisUtil.java From BigData with GNU General Public License v3.0 | 3 votes |
/** * 测试hash中指定的存储是否存在 * * @param String * key * @param String * fieid 存储的名字 * @return 1存在,0不存在 * */ public boolean hexists(String key, String fieid) { // ShardedJedis sjedis = getShardedJedis(); Jedis sjedis = getJedis(); boolean s = sjedis.hexists(key, fieid); returnJedis(sjedis); return s; }