Search in sources :

Example 6 with KeyInfo

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;
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) KeyInfo(doitincloud.rdbcache.models.KeyInfo)

Example 7 with KeyInfo

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;
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) KeyInfo(doitincloud.rdbcache.models.KeyInfo)

Example 8 with KeyInfo

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;
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) KeyInfo(doitincloud.rdbcache.models.KeyInfo)

Example 9 with KeyInfo

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());
    }
}
Also used : AnyKey(doitincloud.rdbcache.supports.AnyKey) CacheOps(doitincloud.rdbcache.services.CacheOps) KeyInfo(doitincloud.rdbcache.models.KeyInfo) Test(org.junit.Test)

Example 10 with KeyInfo

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;
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) KeyInfo(doitincloud.rdbcache.models.KeyInfo) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

KeyInfo (doitincloud.rdbcache.models.KeyInfo)50 KvPair (doitincloud.rdbcache.models.KvPair)29 AnyKey (doitincloud.rdbcache.supports.AnyKey)21 Context (doitincloud.rdbcache.supports.Context)17 KvPairs (doitincloud.rdbcache.supports.KvPairs)17 Test (org.junit.Test)13 ServerErrorException (doitincloud.commons.exceptions.ServerErrorException)9 StopWatch (doitincloud.rdbcache.models.StopWatch)8 BadRequestException (doitincloud.commons.exceptions.BadRequestException)7 SQLException (java.sql.SQLException)4 QueryInfo (doitincloud.rdbcache.queries.QueryInfo)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 MockServletContext (org.springframework.mock.web.MockServletContext)2 NotFoundException (doitincloud.commons.exceptions.NotFoundException)1 CacheOps (doitincloud.rdbcache.services.CacheOps)1 DbaseOps (doitincloud.rdbcache.services.DbaseOps)1 ExpireDbOps (doitincloud.rdbcache.supports.ExpireDbOps)1