use of com.lambdaworks.redis.SetArgs in project moleculer-java by moleculer-java.
the class RedisCacher method set.
@Override
public Promise set(String key, Tree value, int ttl) {
if (status.get() == STATUS_CONNECTED) {
try {
SetArgs args;
if (ttl > 0) {
// Entry-level TTL (in seconds)
args = SetArgs.Builder.ex(ttl);
} else {
// Use the default TTL
args = expiration;
}
Tree root = new CheckedTree(Collections.singletonMap(CONTENT, value.asObject()));
return client.set(key, serializer.write(root), args);
} catch (Exception cause) {
logger.warn("Unable to put data into Redis!", cause);
}
}
return Promise.resolve();
}
Aggregations