Search in sources :

Example 1 with ObjectListReplayDecoder

use of org.redisson.client.protocol.decoder.ObjectListReplayDecoder in project redisson by redisson.

the class RedissonLiveObjectService method findIds.

@Override
public <K> Iterable<K> findIds(Class<?> entityClass, int count) {
    NamingScheme namingScheme = commandExecutor.getObjectBuilder().getNamingScheme(entityClass);
    String pattern = namingScheme.getNamePattern(entityClass);
    RedissonKeys keys = new RedissonKeys(commandExecutor);
    RedisCommand<ListScanResult<String>> command = new RedisCommand<>("SCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ObjectListReplayDecoder<Object>()), new Convertor<Object>() {

        @Override
        public Object convert(Object obj) {
            if (!(obj instanceof String)) {
                return obj;
            }
            return namingScheme.resolveId(obj.toString());
        }
    });
    return keys.getKeysByPattern(command, pattern, 0, count);
}
Also used : ListScanResult(org.redisson.client.protocol.decoder.ListScanResult) NamingScheme(org.redisson.liveobject.resolver.NamingScheme) ListMultiDecoder2(org.redisson.client.protocol.decoder.ListMultiDecoder2) RedisCommand(org.redisson.client.protocol.RedisCommand) ListScanResultReplayDecoder(org.redisson.client.protocol.decoder.ListScanResultReplayDecoder) ObjectListReplayDecoder(org.redisson.client.protocol.decoder.ObjectListReplayDecoder)

Aggregations

RedisCommand (org.redisson.client.protocol.RedisCommand)1 ListMultiDecoder2 (org.redisson.client.protocol.decoder.ListMultiDecoder2)1 ListScanResult (org.redisson.client.protocol.decoder.ListScanResult)1 ListScanResultReplayDecoder (org.redisson.client.protocol.decoder.ListScanResultReplayDecoder)1 ObjectListReplayDecoder (org.redisson.client.protocol.decoder.ObjectListReplayDecoder)1 NamingScheme (org.redisson.liveobject.resolver.NamingScheme)1