@Test public void testDelFields() { List<String> list = new ArrayList<>(); list.add("aa"); list.add("bb"); String[] str = list.toArray(new String[list.size()]); for (int i = 0; i < list.size(); i++) { assertEquals(list.get(i), str[i]); } }
@Override public void delFields() { Set<String> fields = jedis.hkeys(keyName); List<String> delFields = new ArrayList<>(); long currentTime = System.currentTimeMillis(); for (String field : fields) { if (Long.parseLong(jedis.hget(keyName, field)) + maxSpanTime < currentTime) { delFields.add(field); } } try { jedis.hdel(keyName, delFields.toArray(new String[delFields.size()])); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } }
ManagerPersistHash implements ManagerHash { @Override public void delFields() { Set<String> fields = jedis.hkeys(keyName); List<String> delFields = new ArrayList<>(); long currentTime = System.currentTimeMillis(); for (String field : fields) { if (Long.parseLong(jedis.hget(keyName, field)) + maxSpanTime < currentTime) { delFields.add(field); } } try { jedis.hdel(keyName, delFields.toArray(new String[delFields.size()])); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } }
ManagerPersistHash implements ManagerHash { @Override public void delFields() { Set<String> fields = jedis.hkeys(keyName); List<String> delFields = new ArrayList<>(); long currentTime = System.currentTimeMillis(); for (String field : fields) { if (Long.parseLong(jedis.hget(keyName, field)) + maxSpanTime < currentTime) { delFields.add(field); } } try { jedis.hdel(keyName, delFields.toArray(new String[delFields.size()])); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } ManagerPersistHash(Jedis jedis, String keyName, long maxSpanTime); }
ManagerPersistHash implements ManagerHash { @Override public void delFields() { Set<String> fields = jedis.hkeys(keyName); List<String> delFields = new ArrayList<>(); long currentTime = System.currentTimeMillis(); for (String field : fields) { if (Long.parseLong(jedis.hget(keyName, field)) + maxSpanTime < currentTime) { delFields.add(field); } } try { jedis.hdel(keyName, delFields.toArray(new String[delFields.size()])); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } ManagerPersistHash(Jedis jedis, String keyName, long maxSpanTime); @Override void addField(String field); @Override void addFields(String... fields); @Override boolean isExisted(String field); @Override void delFields(); @Override List<String> getFields(); }
ManagerPersistHash implements ManagerHash { @Override public void delFields() { Set<String> fields = jedis.hkeys(keyName); List<String> delFields = new ArrayList<>(); long currentTime = System.currentTimeMillis(); for (String field : fields) { if (Long.parseLong(jedis.hget(keyName, field)) + maxSpanTime < currentTime) { delFields.add(field); } } try { jedis.hdel(keyName, delFields.toArray(new String[delFields.size()])); } catch (Exception e) { logger.error("Exception:{}", LogbackUtil.expection2Str(e)); } } ManagerPersistHash(Jedis jedis, String keyName, long maxSpanTime); @Override void addField(String field); @Override void addFields(String... fields); @Override boolean isExisted(String field); @Override void delFields(); @Override List<String> getFields();  }