本文整理汇总了Java中redis.clients.jedis.Protocol.DEFAULT_DATABASE属性的典型用法代码示例。如果您正苦于以下问题:Java Protocol.DEFAULT_DATABASE属性的具体用法?Java Protocol.DEFAULT_DATABASE怎么用?Java Protocol.DEFAULT_DATABASE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类redis.clients.jedis.Protocol
的用法示例。
在下文中一共展示了Protocol.DEFAULT_DATABASE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JaRedisPool
public JaRedisPool(final String host) {
URI uri = URI.create(host);
if (JedisURIHelper.isValid(uri)) {
String h = uri.getHost();
int port = uri.getPort();
String password = JedisURIHelper.getPassword(uri);
int database = JedisURIHelper.getDBIndex(uri);
this.internalPool = new GenericObjectPool<>(new JaRedisFactory(h, port,
Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, password, database, null),
new GenericObjectPoolConfig());
} else {
this.internalPool = new GenericObjectPool<>(new JaRedisFactory(host,
Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null,
Protocol.DEFAULT_DATABASE, null), new GenericObjectPoolConfig());
}
}
示例2: JedisSentinelPoolExt
public JedisSentinelPoolExt(String masterName, String sentinels, final GenericObjectPoolConfig poolConfig,
final String password, int connectionTimeout, int failMax, boolean masterWriteOnly, String clientName) {
String[] strings = sentinels.split(",");
Collections.addAll(_sentinels, strings);
this.poolConfig = poolConfig;
this.connectionTimeout = connectionTimeout;
if (!StringUtils.isBlank(password)) {
this.password = password;
}
this.database = Protocol.DEFAULT_DATABASE;
this.failMax = failMax;
this.masterName = masterName;
this.masterWriteOnly = masterWriteOnly;
if (!StringUtils.isBlank(clientName)) {
this.clientName = clientName;
}
HostAndPort master = initSentinels(_sentinels, masterName);
initPool(master);
initReadPool();
}
示例3: insertReadPool
/**
* 读池增加新节点
*
* @param hostAndPort
*/
protected synchronized void insertReadPool(HostAndPort hostAndPort) {
boolean exists = false;
for (JedisPoolExt oldJedisPool : jedisReadPools) {
if (oldJedisPool.getHostAndPort().equals(hostAndPort)) {
exists = true;
break;
}
}
if (!exists) {
JedisPoolExt newJedisPool = new JedisPoolExt(poolConfig, hostAndPort.getHost(), hostAndPort.getPort(),
connectionTimeout, password, Protocol.DEFAULT_DATABASE, clientName);
jedisReadPools.add(newJedisPool);
// 新来的节点,可能是之前挂掉后恢复的节点,所以要检查其是否存在于失败列表中,要去除
failMap.remove(hostAndPort);
log.info("Add JedisReadPool at " + hostAndPort);
}
}
示例4: RedisPool
public RedisPool(final String host) {
URI uri = URI.create(host);
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
String h = uri.getHost();
int port = uri.getPort();
String password = JedisURIHelper.getPassword(uri);
int database = 0;
Integer dbIndex = JedisURIHelper.getDBIndex(uri);
if (dbIndex != null) {
database = dbIndex.intValue();
}
this.internalPool = new GenericObjectPool<BinaryJedis>(
new BinaryJedisFactory(h, port, Protocol.DEFAULT_TIMEOUT,
password, database, null),
new GenericObjectPoolConfig());
} else {
this.internalPool = new GenericObjectPool<BinaryJedis>(new BinaryJedisFactory(
host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT,
null, Protocol.DEFAULT_DATABASE, null),
new GenericObjectPoolConfig());
}
}
示例5: DecoratedJedisPool
private DecoratedJedisPool(JedisPoolConfig jedisPoolConfig, String host, int port) {
super(jedisPoolConfig, host, port,
Config.getInstance().getJedisConnectTimeoutMs(),
Config.getInstance().getJedisSocketTimeoutMs(),
Config.getInstance().getRedisPassword(),
Protocol.DEFAULT_DATABASE, null);
this.host = host;
this.port = port;
}
示例6: activateService
@Override
public void activateService()
throws Exception
{
configuration.refresh();
RedisEntityStoreConfiguration config = configuration.get();
String host = config.host().get() == null ? DEFAULT_HOST : config.host().get();
int port = config.port().get() == null ? Protocol.DEFAULT_PORT : config.port().get();
int timeout = config.timeout().get() == null ? Protocol.DEFAULT_TIMEOUT : config.timeout().get();
String password = config.password().get();
int database = config.database().get() == null ? Protocol.DEFAULT_DATABASE : config.database().get();
pool = new JedisPool( new JedisPoolConfig(), host, port, timeout, password, database );
}
示例7: JedisManager
private JedisManager() {
String host = System.getenv("REDIS_HOST");
String port = System.getenv("REDIS_PORT");
factory = new JedisFactory(host == null ? "" : host, port == null ? 6379 : Integer.valueOf(port),
Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE, null);
}
示例8: run
@Override
public void run(BiblioConfiguration configuration, Environment environment) throws Exception {
final IdGenerator idGenerator = new IdGenerator();
environment.jersey().register(new UnexpectedExceptionMapper(idGenerator));
environment.jersey().register(AuthenticationErrorMapper.class);
environment.jersey().register(UnauthorizedExceptionMapper.class);
environment.jersey().register(IllegalArgumentExceptionMapper.class);
final CacheConfiguration cacheConfig = configuration.getCacheConfiguration();
final JedisPool pool = new JedisPool(new GenericObjectPoolConfig(), cacheConfig.getAddress(),
cacheConfig.getPort(), cacheConfig.getSessionExpiration(), cacheConfig.getPassword(), Protocol.DEFAULT_DATABASE);
final Jedis jedis = pool.getResource();
pool.returnResource(jedis);
final UserDao userDao = new UserDao(hibernate.getSessionFactory());
final BookDao bookDao = new BookDao(hibernate.getSessionFactory());
final SessionDao sessionDao = new SessionDao(pool, configuration.getCacheConfiguration());
environment.jersey().register(new UserResource(userDao, sessionDao));
environment.jersey().register(new BarCodeResource(bookDao));
environment.jersey().register(new BookResource(bookDao));
environment.jersey().register(new IsbnResource(bookDao));
environment.jersey().register(new LendResource());
environment.jersey().register(
AuthFactory.binder(
new TokenAuthFactory<>(
new UserAuthenticator(userDao, sessionDao),
"SECURITY REALM",
User.class)));
}
示例9: JaRedisSentinelPool
public JaRedisSentinelPool(String masterName, Set<String> sentinels,
final GenericObjectPoolConfig poolConfig) {
this(masterName, sentinels, poolConfig, Protocol.DEFAULT_TIMEOUT, null,
Protocol.DEFAULT_DATABASE);
}
示例10: ResilientJedisConnectionFactory
public ResilientJedisConnectionFactory(String masterHostName, Set<String> sentinels, String password) {
this(masterHostName, sentinels, password, Protocol.DEFAULT_DATABASE);
}
示例11: HostConfiguration
public HostConfiguration(String host, int port) {
this( host, port, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_DATABASE );
}
示例12: GenericJedisClient
public GenericJedisClient(String host, int port, int timeout, int database) {
super(host, port, timeout);
if ( database != Protocol.DEFAULT_DATABASE) {
this.select(database);
}
}