use of doitincloud.rdbcache.models.KeyInfo in project rdbcache by rdbcache.
the class AbsDbaseRepo method insert.
@Override
public boolean insert(final Context context, final KvPairs pairs, final AnyKey anyKey) {
boolean allOk = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
if (!insert(context, pair, keyInfo)) {
allOk = false;
}
}
return allOk;
}
use of doitincloud.rdbcache.models.KeyInfo in project rdbcache by rdbcache.
the class AbsDbaseRepo method save.
@Override
public boolean save(final Context context, final KvPairs pairs, final AnyKey anyKey) {
boolean allOk = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
if (!save(context, pair, keyInfo)) {
allOk = false;
}
}
return allOk;
}
use of doitincloud.rdbcache.models.KeyInfo in project rdbcache by rdbcache.
the class AbsDbaseRepo method find.
@Override
public boolean find(final Context context, final KvPairs pairs, final AnyKey anyKey) {
boolean allOk = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
if (!find(context, pair, keyInfo)) {
allOk = false;
}
}
return allOk;
}
use of doitincloud.rdbcache.models.KeyInfo in project rdbcache by rdbcache.
the class AnyKeyTest method getAny.
@Test
public void getAny() {
AnyKey anyKey;
KeyInfo keyInfo;
anyKey = new AnyKey();
keyInfo = anyKey.getKeyInfo();
assertNull(keyInfo);
keyInfo = new KeyInfo();
keyInfo.setExpire("100");
keyInfo.setTable("table");
anyKey = new AnyKey(keyInfo);
KeyInfo keyInfo2 = anyKey.getKeyInfo();
assertNotNull(keyInfo2);
assertTrue(keyInfo == keyInfo2);
keyInfo2 = anyKey.get(0);
assertNotNull(keyInfo2);
assertTrue(keyInfo == keyInfo2);
CacheOps cacheOps = new CacheOps();
cacheOps.init();
cacheOps.handleEvent(null);
AppCtx.setCacheOps(cacheOps);
try {
for (int i = 0; i < 10; i++) {
keyInfo = anyKey.getAny(i);
assertNotNull(keyInfo);
if (i == 0)
assertFalse(keyInfo.getIsNew());
else
assertTrue(keyInfo.getIsNew());
assertEquals(i + 1, anyKey.size());
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getCause().getMessage());
}
}
use of doitincloud.rdbcache.models.KeyInfo in project rdbcache by rdbcache.
the class SimpleKeyInfoRepo method find.
@Override
public boolean find(Context context, KvPairs pairs, AnyKey anyKey) {
LOGGER.trace("find pairs(" + pairs.size() + ") anyKey(" + anyKey.size() + ")");
boolean foundAll = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
String key = pair.getId();
Map<String, Object> map = (Map<String, Object>) data.get(key);
if (map == null) {
foundAll = false;
LOGGER.trace("find: Not Found " + key);
continue;
} else {
keyInfo = Utils.toPojo(map, KeyInfo.class);
anyKey.set(i, keyInfo);
LOGGER.trace("find: Found " + key);
}
}
return foundAll;
}
Aggregations