
io.vertx.tp.plugin.redis.cache.L1ChannelSync Maven / Gradle / Ivy
The newest version!
package io.vertx.tp.plugin.redis.cache;
import io.vertx.tp.plugin.redis.RedisInfix;
import io.horizon.uca.log.Annal;
import io.vertx.up.util.Ut;
import redis.clients.jedis.Jedis;
import java.util.Objects;
/**
* @author Lang
*/
class L1ChannelSync {
private final static Annal LOGGER = Annal.get(L1ChannelSync.class);
private final transient Jedis jedis;
L1ChannelSync() {
this.jedis = RedisInfix.getJClient();
}
@SuppressWarnings("all")
T read(final String key) {
/*
* Async convert to type
*/
if (Objects.isNull(this.jedis)) {
// Nothing returned
return null;
} else {
final String literal = this.jedis.get(key);
if (Ut.isNil(literal)) {
LOGGER.info(CacheMsg.HIT_FAILURE, key);
return null;
} else {
if (Ut.isJObject(literal)) {
/*
* Data Found
*/
LOGGER.info(CacheMsg.HIT_DATA, key);
return (T) Ut.toJObject(literal);
} else if (Ut.isJArray(literal)) {
LOGGER.info(CacheMsg.HIT_DATA, key);
return (T) Ut.toJArray(literal);
} else {
/*
* Secondary read
*/
LOGGER.info(CacheMsg.HIT_SECONDARY, literal, key);
return this.read(literal);
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy