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

The following examples show how to use org.redisson.client.codec.StringCodec#INSTANCE . These examples are extracted from open source projects. 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 Project: redisson   File: RedissonList.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void removeListener(int listenerId) {
    RPatternTopic addTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:rpush");
    addTopic.removeListener(listenerId);

    RPatternTopic remTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:lrem");
    remTopic.removeListener(listenerId);

    RPatternTopic trimTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:ltrim");
    trimTopic.removeListener(listenerId);

    RPatternTopic setTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:lset");
    setTopic.removeListener(listenerId);

    RPatternTopic insertTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:linsert");
    insertTopic.removeListener(listenerId);

    super.removeListener(listenerId);
}
 
Example 2
Source Project: redisson   File: RedissonList.java    License: 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, "[email protected]*:rpush");
    addTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic remTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:lrem");
    remTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic trimTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:ltrim");
    trimTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic setTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:lset");
    setTopic.removeListenerAsync(listenerId).onComplete(listener);

    RPatternTopic insertTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:linsert");
    insertTopic.removeListenerAsync(listenerId).onComplete(listener);

    removeListenersAsync(listenerId, listener);

    return result;
}
 
Example 3
Source Project: redisson   File: RedissonObject.java    License: 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 Project: redisson   File: RedissonObject.java    License: 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 Project: redisson   File: RedissonObject.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void removeListener(int listenerId) {
    RPatternTopic expiredTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:expired");
    expiredTopic.removeListener(listenerId);

    RPatternTopic deletedTopic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, "[email protected]*:del");
    deletedTopic.removeListener(listenerId);
}
 
Example 6
Source Project: redisson   File: RedissonObject.java    License: 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, "[email protected]*:expired");
    expiredTopic.removeListenerAsync(listenerId).onComplete(listener);

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

    super.removeListener(listenerId);
}
 
Example 8
Source Project: redisson   File: RedissonBucket.java    License: 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, "[email protected]*:set");
    setTopic.removeListenerAsync(listenerId).onComplete(listener);
    removeListenersAsync(listenerId, listener);
    return result;
}
 
Example 9
Source Project: redisson   File: RedissonBuckets.java    License: 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 Project: redisson   File: AsyncRemoteProxy.java    License: 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 Project: redisson   File: BatchCommandData.java    License: 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 Project: redisson   File: BaseRemoteService.java    License: 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 Project: redisson   File: RedissonLexSortedSet.java    License: Apache License 2.0 4 votes vote down vote up
public RedissonLexSortedSet(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) {
    super(StringCodec.INSTANCE, commandExecutor, name, redisson);
}