@Test public void testGetMulti() { String[] keys = MemCacheUtil.toKeys(new String[] { "123", "456", "789" }, "module.c"); MemCacheTemplate<String> memCacheTemplate = getMemCacheTemplate(); if (memCacheTemplate.set(keys[0], "dsadsadsadsadas")) { Map<String, String> map = memCacheTemplate.getMulti(keys); Assert.assertEquals(true, map.containsKey(keys[0])); Assert.assertEquals(false, map.containsKey(keys[1])); Assert.assertEquals(false, map.containsKey(keys[2])); } }
@Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } } String[] leftkeys = null; if(keys.length > values.size()) { leftkeys = getMulti(values, keys, master); } if (keys.length > values.size() && slave != null) { String[] leftkeysSlave = getMulti(values, keys, slave); if (leftkeysSlave != null && setbackMaster == true) { set(values, leftkeysSlave, expireTime, master); } } if (oneL1 != null && leftkeys != null) { set(values, leftkeys, getExpireTimeL1(), oneL1); } return values; }
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } } String[] leftkeys = null; if(keys.length > values.size()) { leftkeys = getMulti(values, keys, master); } if (keys.length > values.size() && slave != null) { String[] leftkeysSlave = getMulti(values, keys, slave); if (leftkeysSlave != null && setbackMaster == true) { set(values, leftkeysSlave, expireTime, master); } } if (oneL1 != null && leftkeys != null) { set(values, leftkeys, getExpireTimeL1(), oneL1); } return values; } }
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } } String[] leftkeys = null; if(keys.length > values.size()) { leftkeys = getMulti(values, keys, master); } if (keys.length > values.size() && slave != null) { String[] leftkeysSlave = getMulti(values, keys, slave); if (leftkeysSlave != null && setbackMaster == true) { set(values, leftkeysSlave, expireTime, master); } } if (oneL1 != null && leftkeys != null) { set(values, leftkeys, getExpireTimeL1(), oneL1); } return values; }  }
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } } String[] leftkeys = null; if(keys.length > values.size()) { leftkeys = getMulti(values, keys, master); } if (keys.length > values.size() && slave != null) { String[] leftkeysSlave = getMulti(values, keys, slave); if (leftkeysSlave != null && setbackMaster == true) { set(values, leftkeysSlave, expireTime, master); } } if (oneL1 != null && leftkeys != null) { set(values, leftkeys, getExpireTimeL1(), oneL1); } return values; }  @Override T get(String key); @Override Map<String, T> getMulti(String[] keys); @Override boolean set(String key, T value); @Override boolean set(String key, T value, Date expdate); @SuppressWarnings("unchecked") @Override CasValue<T> getCas(String key); @Override boolean cas(String key, CasValue<T> casValue); @Override boolean cas(String key, CasValue<T> casValue, Date expdate); @Override boolean delete(String key); void setExpire(long expire); void setExpireL1(long expireL1); Date getExpireTime(); Date getExpireTimeL1(); MemcacheClient getMaster(); List<MemcacheClient> getMasterL1List(); MemcacheClient getSlave(); List<MemcacheClient> getSlaveL1List(); boolean isSetbackMaster(); void setMaster(MemcacheClient master); void setMasterL1List(List<MemcacheClient> masterL1List); void setSlave(MemcacheClient slave); void setSlaveL1List(List<MemcacheClient> slaveL1List); void setSetbackMaster(boolean setbackMaster); boolean isMasterAsOneL1(); void setMasterAsOneL1(boolean masterAsOneL1); String getWirtePolicy(); void setWirtePolicy(String wirtePolicy); }
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } } String[] leftkeys = null; if(keys.length > values.size()) { leftkeys = getMulti(values, keys, master); } if (keys.length > values.size() && slave != null) { String[] leftkeysSlave = getMulti(values, keys, slave); if (leftkeysSlave != null && setbackMaster == true) { set(values, leftkeysSlave, expireTime, master); } } if (oneL1 != null && leftkeys != null) { set(values, leftkeys, getExpireTimeL1(), oneL1); } return values; }  @Override T get(String key); @Override Map<String, T> getMulti(String[] keys); @Override boolean set(String key, T value); @Override boolean set(String key, T value, Date expdate); @SuppressWarnings("unchecked") @Override CasValue<T> getCas(String key); @Override boolean cas(String key, CasValue<T> casValue); @Override boolean cas(String key, CasValue<T> casValue, Date expdate); @Override boolean delete(String key); void setExpire(long expire); void setExpireL1(long expireL1); Date getExpireTime(); Date getExpireTimeL1(); MemcacheClient getMaster(); List<MemcacheClient> getMasterL1List(); MemcacheClient getSlave(); List<MemcacheClient> getSlaveL1List(); boolean isSetbackMaster(); void setMaster(MemcacheClient master); void setMasterL1List(List<MemcacheClient> masterL1List); void setSlave(MemcacheClient slave); void setSlaveL1List(List<MemcacheClient> slaveL1List); void setSetbackMaster(boolean setbackMaster); boolean isMasterAsOneL1(); void setMasterAsOneL1(boolean masterAsOneL1); String getWirtePolicy(); void setWirtePolicy(String wirtePolicy);  }