Java Code Examples for org.redisson.client.codec.StringCodec#INSTANCE

The following examples show how to use org.redisson.client.codec.StringCodec#INSTANCE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonList.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
public void removeListener(int listenerId) {
    RPatternTopic addTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:rpush");
    addTopic.removeListener(listenerId);

    RPatternTopic remTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:lrem");
    remTopic.removeListener(listenerId);

    RPatternTopic trimTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:ltrim");
    trimTopic.removeListener(listenerId);

    RPatternTopic setTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:lset");
    setTopic.removeListener(listenerId);

    RPatternTopic insertTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:linsert");
    insertTopic.removeListener(listenerId);

    super.removeListener(listenerId);
}
 
Example 2
Source File: RedissonList.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
public RFuture<Void> removeListenerAsync(int listenerId) {
    RPromise<Void> result = new RedissonPromise<>();
    CountableListener<Void> listener = new CountableListener<>(result, null, 5);

    RPatternTopic addTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:rpush");
    addTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic remTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:lrem");
    remTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic trimTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:ltrim");
    trimTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic setTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:lset");
    setTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic insertTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:linsert");
    insertTopic.removeListenerAsync(listenerId).onComplete(listener);

    removeListenersAsync(listenerId, listener);

    return result;
}
 
Example 3
Source File: RedissonObject.java    From redisson with Apache License 2.0 5 votes vote down vote up
protected final <T extends ObjectListener> int addListener(String name, T listener, BiConsumer<T, String> consumer) {
    RPatternTopic topic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, name);
    return topic.addListener(String.class, (pattern, channel, msg) -> {
        if (msg.equals(getName())) {
            consumer.accept(listener, msg);
        }
    });
}
 
Example 4
Source File: RedissonObject.java    From redisson with Apache License 2.0 5 votes vote down vote up
protected final <T extends ObjectListener> RFuture<Integer> addListenerAsync(String name, T listener, BiConsumer<T, String> consumer) {
    RPatternTopic topic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, name);
    return topic.addListenerAsync(String.class, (pattern, channel, msg) -> {
        if (msg.equals(getName())) {
            consumer.accept(listener, msg);
        }
    });
}
 
Example 5
Source File: RedissonObject.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public void removeListener(int listenerId) {
    RPatternTopic expiredTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:expired");
    expiredTopic.removeListener(listenerId);

    RPatternTopic deletedTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:del");
    deletedTopic.removeListener(listenerId);
}
 
Example 6
Source File: RedissonObject.java    From redisson with Apache License 2.0 5 votes vote down vote up
protected final void removeListenersAsync(int listenerId, CountableListener<Void> listener) {
    RPatternTopic expiredTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:expired");
    expiredTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic deletedTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:del");
    deletedTopic.removeListenerAsync(listenerId).onComplete(listener);
}
 
Example 7
Source File: RedissonBucket.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public void removeListener(int listenerId) {
    RPatternTopic expiredTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:set");
    expiredTopic.removeListener(listenerId);

    super.removeListener(listenerId);
}
 
Example 8
Source File: RedissonBucket.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public RFuture<Void> removeListenerAsync(int listenerId) {
    RPromise<Void> result = new RedissonPromise<>();
    CountableListener<Void> listener = new CountableListener<>(result, null, 3);

    RPatternTopic setTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "__keyevent@*:set");
    setTopic.removeListenerAsync(listenerId).onComplete(listener);
    removeListenersAsync(listenerId, listener);
    return result;
}
 
Example 9
Source File: RedissonBuckets.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public <V> RFuture<Map<String, V>> getAsync(String... keys) {
    if (keys.length == 0) {
        return RedissonPromise.newSucceededFuture(Collections.emptyMap());
    }
    
    Codec commandCodec = new CompositeCodec(StringCodec.INSTANCE, codec, codec);
    
    RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("MGET", new MapGetAllDecoder(Arrays.<Object>asList(keys), 0));
    return commandExecutor.readBatchedAsync(commandCodec, command, new SlotCallback<Map<Object, Object>, Map<String, V>>() {
        Map<String, V> results = new ConcurrentHashMap<>();

        @Override
        public void onSlotResult(Map<Object, Object> result) {
            for (Map.Entry<Object, Object> entry : result.entrySet()) {
                if (entry.getKey() != null && entry.getValue() != null) {
                    results.put((String) entry.getKey(), (V) entry.getValue());
                }
            }
        }

        @Override
        public Map<String, V> onFinish() {
            return results;
        }

        @Override
        public RedisCommand<Map<Object, Object>> createCommand(Object param) {
            return new RedisCommand<Map<Object, Object>>("MGET", new BucketsDecoder(param.toString()));
        }
    }, keys);
}
 
Example 10
Source File: AsyncRemoteProxy.java    From redisson with Apache License 2.0 5 votes vote down vote up
private void cancelExecution(RemoteInvocationOptions optionsCopy,
        boolean mayInterruptIfRunning, RemotePromise<Object> remotePromise, String cancelRequestMapName) {
    RMap<String, RemoteServiceCancelRequest> canceledRequests = new RedissonMap<>(new CompositeCodec(StringCodec.INSTANCE, codec, codec), commandExecutor, cancelRequestMapName, null, null, null);
    canceledRequests.fastPutAsync(remotePromise.getRequestId().toString(), new RemoteServiceCancelRequest(mayInterruptIfRunning, false));
    canceledRequests.expireAsync(60, TimeUnit.SECONDS);
    
    // subscribe for async result if it's not expected before
    if (!optionsCopy.isResultExpected()) {
        RemoteInvocationOptions options = new RemoteInvocationOptions(optionsCopy);
        options.expectResultWithin(60, TimeUnit.SECONDS);
        RFuture<RRemoteServiceResponse> responseFuture = pollResponse(options.getExecutionTimeoutInMillis(), remotePromise.getRequestId(), false);
        awaitResultAsync(options, remotePromise, responseFuture);
    }
}
 
Example 11
Source File: BatchCommandData.java    From redisson with Apache License 2.0 4 votes vote down vote up
public BatchCommandData(RedisCommand<T> command, Object[] params, int index) {
    this(new RedissonPromise<R>(), StringCodec.INSTANCE, command, params, index);
}
 
Example 12
Source File: BaseRemoteService.java    From redisson with Apache License 2.0 4 votes vote down vote up
protected <K, V> RMap<K, V> getMap(String name) {
    return new RedissonMap<>(new CompositeCodec(StringCodec.INSTANCE, codec, codec), commandExecutor, name, null, null, null);
}
 
Example 13
Source File: RedissonLexSortedSet.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonLexSortedSet(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) {
    super(StringCodec.INSTANCE, commandExecutor, name, redisson);
}