use of redis.clients.jedis.JedisPool in project tech by ffyyhh995511.
the class JedisService method mset.
/**
* 批量字符串存储
* @param keysvalues
*/
public String mset(String... keysvalues) {
String rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.mset(keysvalues);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return rs;
}
use of redis.clients.jedis.JedisPool in project grakn by graknlabs.
the class EngineContext method before.
@Override
protected final void before() throws Throwable {
RestAssured.baseURI = uri().toURI().toString();
if (!config.getProperty(GraknConfigKey.TEST_START_EMBEDDED_COMPONENTS)) {
return;
}
SimpleURI redisURI = new SimpleURI(Iterables.getOnlyElement(config.getProperty(GraknConfigKey.REDIS_HOST)));
jedisPool = new JedisPool(redisURI.getHost(), redisURI.getPort());
// To ensure consistency b/w test profiles and configuration files, when not using Janus
// for a unit tests in an IDE, add the following option:
// -Dgrakn.conf=../conf/test/tinker/grakn.properties
//
// When using janus, add -Dgrakn.test-profile=janus
//
// The reason is that the default configuration of Grakn uses the Janus Factory while the default
// test profile is tinker: so when running a unit test within an IDE without any extra parameters,
// we end up wanting to use the JanusFactory but without starting Cassandra first.
LOG.info("starting engine...");
// start engine
setRestAssuredUri(config);
spark = Service.ignite();
config.setConfigProperty(GraknConfigKey.REDIS_HOST, Collections.singletonList("localhost:" + redis.port()));
RedisWrapper redis = RedisWrapper.create(config);
server = startGraknEngineServer(redis);
LOG.info("engine started on " + uri());
}
use of redis.clients.jedis.JedisPool in project dubbo by alibaba.
the class RedisRegistry method doUnregister.
@Override
public void doUnregister(URL url) {
String key = toCategoryPath(url);
String value = url.toFullString();
RpcException exception = null;
boolean success = false;
for (Map.Entry<String, JedisPool> entry : jedisPools.entrySet()) {
JedisPool jedisPool = entry.getValue();
try {
Jedis jedis = jedisPool.getResource();
try {
jedis.hdel(key, value);
jedis.publish(key, Constants.UNREGISTER);
success = true;
if (!replicate) {
// If the server side has synchronized data, just write a single machine
break;
}
} finally {
jedis.close();
}
} catch (Throwable t) {
exception = new RpcException("Failed to unregister service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
}
}
if (exception != null) {
if (success) {
logger.warn(exception.getMessage(), exception);
} else {
throw exception;
}
}
}
use of redis.clients.jedis.JedisPool in project jfinal by jfinal.
the class RedisPlugin method start.
public boolean start() {
JedisPool jedisPool;
if (port != null && timeout != null && password != null && database != null && clientName != null)
jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password, database, clientName);
else if (port != null && timeout != null && password != null && database != null)
jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password, database);
else if (port != null && timeout != null && password != null)
jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password);
else if (port != null && timeout != null)
jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout);
else if (port != null)
jedisPool = new JedisPool(jedisPoolConfig, host, port);
else
jedisPool = new JedisPool(jedisPoolConfig, host);
if (serializer == null)
serializer = FstSerializer.me;
if (keyNamingPolicy == null)
keyNamingPolicy = IKeyNamingPolicy.defaultKeyNamingPolicy;
Cache cache = new Cache(cacheName, jedisPool, serializer, keyNamingPolicy);
Redis.addCache(cache);
return true;
}
use of redis.clients.jedis.JedisPool in project gitblit by gitblit.
the class RedisTicketService method createPool.
private JedisPool createPool(String url) {
JedisPool pool = null;
if (!StringUtils.isEmpty(url)) {
try {
URI uri = URI.create(url);
if (uri.getScheme() != null && uri.getScheme().equalsIgnoreCase("redis")) {
int database = Protocol.DEFAULT_DATABASE;
String password = null;
if (uri.getUserInfo() != null) {
password = uri.getUserInfo().split(":", 2)[1];
}
if (uri.getPath().indexOf('/') > -1) {
database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
}
pool = new JedisPool(new GenericObjectPoolConfig(), uri.getHost(), uri.getPort(), Protocol.DEFAULT_TIMEOUT, password, database);
} else {
pool = new JedisPool(url);
}
} catch (JedisException e) {
log.error("failed to create a Redis pool!", e);
}
}
return pool;
}
Aggregations