Search in sources :

Example 1 with DynamicKeyGroup

use of io.rx_cache2.DynamicKeyGroup in project RxCache by VictorAlbertos.

the class ProxyTranslatorTest method When_Use_Evict_Dynamic_Key_Group_Providing_Dynamic_Key_Group_Not_Throw_Exception.

@Test
public void When_Use_Evict_Dynamic_Key_Group_Providing_Dynamic_Key_Group_Not_Throw_Exception() throws NoSuchMethodException {
    Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMockEvictDynamicKeyGroupProvidingDynamicKeyGroup", Observable.class, DynamicKeyGroup.class, EvictDynamicKeyGroup.class);
    Object[] data = { Observable.just(new Object[] {}), new DynamicKeyGroup("1", "1"), new EvictDynamicKeyGroup(true) };
    proxyTranslatorUT.processMethod(mockMethod, data);
}
Also used : DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) EvictDynamicKeyGroup(io.rx_cache2.EvictDynamicKeyGroup) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with DynamicKeyGroup

use of io.rx_cache2.DynamicKeyGroup in project RxCache by VictorAlbertos.

the class ProxyTranslator method getDynamicKey.

private String getDynamicKey(Method method, Object[] objectsMethod) {
    DynamicKey dynamicKey = getObjectFromMethodParam(method, DynamicKey.class, objectsMethod);
    if (dynamicKey != null)
        return dynamicKey.getDynamicKey().toString();
    DynamicKeyGroup dynamicKeyGroup = getObjectFromMethodParam(method, DynamicKeyGroup.class, objectsMethod);
    if (dynamicKeyGroup != null)
        return dynamicKeyGroup.getDynamicKey().toString();
    return "";
}
Also used : DynamicKeyGroup(io.rx_cache2.DynamicKeyGroup) DynamicKey(io.rx_cache2.DynamicKey)

Example 3 with DynamicKeyGroup

use of io.rx_cache2.DynamicKeyGroup in project RxCache by VictorAlbertos.

the class SaveRecord method save.

void save(final String providerKey, final String dynamicKey, final String dynamicKeyGroup, final Object data, final Long lifeTime, final boolean isExpirable, final boolean isEncrypted) {
    String composedKey = composeKey(providerKey, dynamicKey, dynamicKeyGroup);
    Record record = new Record(data, isExpirable, lifeTime);
    memory.put(composedKey, record);
    if (persistence.storedMB() >= maxMgPersistenceCache) {
        System.out.println(Locale.RECORD_CAN_NOT_BE_PERSISTED_BECAUSE_WOULD_EXCEED_THRESHOLD_LIMIT);
    } else {
        persistence.saveRecord(composedKey, record, isEncrypted, encryptKey);
    }
    evictExpirableRecordsPersistence.startTaskIfNeeded(isEncrypted);
}
Also used : Record(io.rx_cache2.internal.Record)

Aggregations

DynamicKeyGroup (io.rx_cache2.DynamicKeyGroup)2 DynamicKey (io.rx_cache2.DynamicKey)1 EvictDynamicKeyGroup (io.rx_cache2.EvictDynamicKeyGroup)1 Record (io.rx_cache2.internal.Record)1 Method (java.lang.reflect.Method)1 Test (org.junit.Test)1