@Override public Flux<K> scan(ScanOptions options) { Assert.notNull(options, "ScanOptions must not be null!"); return createFlux(connection -> connection.keyCommands().scan(options)) // .map(this::readKey); }
@Override public Mono<Boolean> delete(H key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override public Mono<Boolean> delete(K key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override public Mono<Boolean> delete(K key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override public Mono<Boolean> delete(K key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override public Mono<Boolean> delete(K key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override public Mono<Boolean> delete(K key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override public Mono<Boolean> delete(K key) { Assert.notNull(key, "Key must not be null!"); return template.createMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0); }
@Override @SafeVarargs public final Mono<Long> delete(K... keys) { Assert.notNull(keys, "Keys must not be null!"); Assert.notEmpty(keys, "Keys must not be empty!"); Assert.noNullElements(keys, "Keys must not contain null elements!"); if (keys.length == 1) { return createMono(connection -> connection.keyCommands().del(rawKey(keys[0]))); } Mono<List<ByteBuffer>> listOfKeys = Flux.fromArray(keys).map(this::rawKey).collectList(); return createMono(connection -> listOfKeys.flatMap(rawKeys -> connection.keyCommands().mDel(rawKeys))); }
@Override @SafeVarargs public final Mono<Long> unlink(K... keys) { Assert.notNull(keys, "Keys must not be null!"); Assert.notEmpty(keys, "Keys must not be empty!"); Assert.noNullElements(keys, "Keys must not contain null elements!"); if (keys.length == 1) { return createMono(connection -> connection.keyCommands().unlink(rawKey(keys[0]))); } Mono<List<ByteBuffer>> listOfKeys = Flux.fromArray(keys).map(this::rawKey).collectList(); return createMono(connection -> listOfKeys.flatMap(rawKeys -> connection.keyCommands().mUnlink(rawKeys))); }
@Override public Mono<Boolean> persist(K key) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.keyCommands().persist(rawKey(key))); }
@Override public Mono<Boolean> hasKey(K key) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.keyCommands().exists(rawKey(key))); }
@Override public Mono<DataType> type(K key) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.keyCommands().type(rawKey(key))); }
@Override public Mono<Boolean> move(K key, int dbIndex) { Assert.notNull(key, "Key must not be null!"); return createMono(connection -> connection.keyCommands().move(rawKey(key), dbIndex)); }
@Override public Mono<Boolean> rename(K oldKey, K newKey) { Assert.notNull(oldKey, "Old key must not be null!"); Assert.notNull(newKey, "New Key must not be null!"); return createMono(connection -> connection.keyCommands().rename(rawKey(oldKey), rawKey(newKey))); }
@Override public Mono<Boolean> renameIfAbsent(K oldKey, K newKey) { Assert.notNull(oldKey, "Old key must not be null!"); Assert.notNull(newKey, "New Key must not be null!"); return createMono(connection -> connection.keyCommands().renameNX(rawKey(oldKey), rawKey(newKey))); }
@Override public Flux<K> keys(K pattern) { Assert.notNull(pattern, "Pattern must not be null!"); return createFlux(connection -> connection.keyCommands().keys(rawKey(pattern))) // .flatMap(Flux::fromIterable) // .map(this::readKey); }
@Override public Mono<Boolean> expireAt(K key, Instant expireAt) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(expireAt, "Expire at must not be null!"); if (expireAt.getNano() == 0) { return createMono(connection -> connection.keyCommands() // .expireAt(rawKey(key), expireAt)); } return createMono(connection -> connection.keyCommands().pExpireAt(rawKey(key), expireAt)); }
@Override public Mono<Boolean> expire(K key, Duration timeout) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(timeout, "Timeout must not be null!"); if (timeout.getNano() == 0) { return createMono(connection -> connection.keyCommands() // .expire(rawKey(key), timeout)); } return createMono(connection -> connection.keyCommands().pExpire(rawKey(key), timeout)); }
@Override public Mono<Long> unlink(Publisher<K> keys) { Assert.notNull(keys, "Keys must not be null!"); return createFlux(connection -> connection.keyCommands() // .mUnlink(Flux.from(keys).map(this::rawKey).buffer(128)) // .map(CommandResponse::getOutput)) // .collect(Collectors.summingLong(value -> value)); }