Search in sources :

Example 41 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheMapUtil method put.

@Deprecated
public static <T> T put(CacheConfigBean cacheConfigBean, String key, String field, T value, int seconds) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheMapPut", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", key);
            put("field", field);
            put("value", value);
            put("timeout", seconds);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    if (unitResponseObject.succeeded())
        return value;
    else
        return null;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 42 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheMapUtil method putAll.

public static void putAll(CacheConfigBean cacheConfigBean, String key, Map maps) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheMapPutAll", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", key);
            put("maps", maps);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 43 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheMapUtil method getAll.

public static <K, V> Map<K, V> getAll(CacheConfigBean cacheConfigBean, String key, Class<K> kClazz, Class<V> vClazz) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheMapGetAll", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", key);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    Map<String, String> map = null;
    if (unitResponseObject.getData() != null)
        map = Map.class.cast(unitResponseObject.getData());
    if (map == null || map.isEmpty())
        return new HashMap<>();
    Map<K, V> maps = new HashMap<>();
    map.forEach((_key, _value) -> {
        maps.put(kClazz.cast(_key), Reflection.toType(_value, vClazz));
    });
    return maps;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 44 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheObjectUtil method luaScript.

@Deprecated
public static Object luaScript(CacheConfigBean cacheConfigBean, String scripts, List<String> keys, List<String> params) {
    UnitResponse response = SyncXian.call(CacheService.CACHE_SERVICE, "cacheLua", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("scripts", scripts);
            put("keys", keys);
            put("params", params);
        }
    });
    response.throwExceptionIfNotSuccess();
    return response.getData();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Example 45 with UnitResponse

use of info.xiancloud.core.message.UnitResponse in project xian by happyyangyuan.

the class CacheObjectUtil method increment.

public static long increment(CacheConfigBean cacheConfigBean, String cacheKey) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheIncrement", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("key", cacheKey);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    return (long) unitResponseObject.getData();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UnitResponse(info.xiancloud.core.message.UnitResponse)

Aggregations

UnitResponse (info.xiancloud.core.message.UnitResponse)106 JSONObject (com.alibaba.fastjson.JSONObject)74 HashMap (java.util.HashMap)22 UnitRequest (info.xiancloud.core.message.UnitRequest)17 NotifyHandler (info.xiancloud.core.NotifyHandler)16 JSONArray (com.alibaba.fastjson.JSONArray)9 Unit (info.xiancloud.core.Unit)6 UnitMeta (info.xiancloud.core.UnitMeta)6 CacheGroup (info.xiancloud.cache.service.CacheGroup)5 Group (info.xiancloud.core.Group)5 Input (info.xiancloud.core.Input)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Redis (info.xiancloud.cache.redis.Redis)4 CacheConfigBean (info.xiancloud.core.support.cache.CacheConfigBean)4 ThreadPoolManager (info.xiancloud.core.thread_pool.ThreadPoolManager)3 LOG (info.xiancloud.core.util.LOG)3 Set (java.util.Set)3 Test (org.junit.Test)3 MessageType (info.xiancloud.core.distribution.MessageType)2 UnitUndefinedException (info.xiancloud.core.distribution.exception.UnitUndefinedException)2