@Test public void testAddField() { Jedis jedis = pool.getResource(); jedis.auth(password); try { ManagerExpiredHash managerExpiredHash = new ManagerExpiredHash(jedis, KEY_NAME, EXPIRE, MAX_SPAN_TIME); managerExpiredHash.addFields(FIELDS); Set<String> allField = jedis.hkeys(KEY_NAME); for (String field : allField) { boolean flag = Boolean.FALSE; for (String f : FIELDS) { if (field.equals(f)) { flag = Boolean.TRUE; } } assertTrue(flag); } jedis.del(KEY_NAME); } finally { pool.returnResource(jedis); } }
@Override public void addField(String field) { try { jedis.hset(keyName, field, System.currentTimeMillis() + ""); jedis.set(field, ONE); jedis.pexpire(field, expire); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } }
ManagerExpiredHash implements ManagerHash { @Override public void addField(String field) { try { jedis.hset(keyName, field, System.currentTimeMillis() + ""); jedis.set(field, ONE); jedis.pexpire(field, expire); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } }
ManagerExpiredHash implements ManagerHash { @Override public void addField(String field) { try { jedis.hset(keyName, field, System.currentTimeMillis() + ""); jedis.set(field, ONE); jedis.pexpire(field, expire); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } ManagerExpiredHash(Jedis jedis, String keyName, long expire, long maxSpanTime); }
ManagerExpiredHash implements ManagerHash { @Override public void addField(String field) { try { jedis.hset(keyName, field, System.currentTimeMillis() + ""); jedis.set(field, ONE); jedis.pexpire(field, expire); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } ManagerExpiredHash(Jedis jedis, String keyName, long expire, long maxSpanTime); @Override void addField(String field); @Override void addFields(String... fields); @Override List<String> getFields(); @Override boolean isExisted(String field); @Override void delFields(); }
ManagerExpiredHash implements ManagerHash { @Override public void addField(String field) { try { jedis.hset(keyName, field, System.currentTimeMillis() + ""); jedis.set(field, ONE); jedis.pexpire(field, expire); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } ManagerExpiredHash(Jedis jedis, String keyName, long expire, long maxSpanTime); @Override void addField(String field); @Override void addFields(String... fields); @Override List<String> getFields(); @Override boolean isExisted(String field); @Override void delFields();  }