• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RedisConnectionUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.data.redis.core.RedisConnectionUtils的典型用法代码示例。如果您正苦于以下问题:Java RedisConnectionUtils类的具体用法?Java RedisConnectionUtils怎么用?Java RedisConnectionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RedisConnectionUtils类属于org.springframework.data.redis.core包,在下文中一共展示了RedisConnectionUtils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doHealthCheck

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
	RedisConnection connection = RedisConnectionUtils
			.getConnection(this.redisConnectionFactory);
	try {
		if (connection instanceof RedisClusterConnection) {
			ClusterInfo clusterInfo = ((RedisClusterConnection) connection)
					.clusterGetClusterInfo();
			builder.up().withDetail("cluster_size", clusterInfo.getClusterSize())
					.withDetail("slots_up", clusterInfo.getSlotsOk())
					.withDetail("slots_fail", clusterInfo.getSlotsFail());
		}
		else {
			Properties info = connection.info();
			builder.up().withDetail(VERSION, info.getProperty(REDIS_VERSION));
		}
	}
	finally {
		RedisConnectionUtils.releaseConnection(connection,
				this.redisConnectionFactory);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:RedisHealthIndicator.java


示例2: monitor

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Scheduled(fixedDelay = 5000)
public void monitor() {
    DefaultCacheStatistics statistics = new DefaultCacheStatistics();
    // @see http://redis.io/commands/INFO
    RedisConnection connection = RedisConnectionUtils.getConnection(this.redisConnectionFactory);
    try {
        Properties props = connection.info();
        Long hitCount = Long.parseLong(props.getProperty("keyspace_hits"));
        Long missCount = Long.parseLong(props.getProperty("keyspace_misses"));
        statistics.setGetCacheCounts(hitCount, missCount);
        // we do not currently have a way of calculating the cache size, so we have to filter
        List<Metric<?>> metrics = statistics
                                    .toMetrics("cache.")
                                        .stream()
                                            .filter(f -> !f.getName().contains(".size"))
                                            .collect(Collectors.toList());
        metrics.forEach(m -> metricServices.submit(m.getName(), (Double) m.getValue()));
    } finally {
        RedisConnectionUtils.releaseConnection(connection, this.redisConnectionFactory);
    }
}
 
开发者ID:fastnsilver,项目名称:xlator,代码行数:22,代码来源:RedisCacheMonitor.java


示例3: setnx

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Override
public boolean setnx(String key, Serializable value) {
    RedisConnectionFactory factory = redisTemplate.getConnectionFactory();
    RedisConnection redisConnection = null;
    try {
        redisConnection = RedisConnectionUtils.getConnection(factory);
        if (redisConnection == null) {
            return redisTemplate.boundValueOps(key).setIfAbsent(value);
        }
        return redisConnection.setNX(keySerializer.serialize(key), valueSerializer.serialize(value));
    } finally {
        RedisConnectionUtils.releaseConnection(redisConnection, factory);
    }
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:15,代码来源:RedisHelper.java


示例4: lock

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Override
public boolean lock(String key) {
    RedisConnectionFactory factory = redisTemplate.getConnectionFactory();
    RedisConnection redisConnection = null;
    try {
        redisConnection = RedisConnectionUtils.getConnection(factory);
        if (redisConnection == null) {
            return redisTemplate.boundValueOps(key).setIfAbsent("0");
        }
        return redisConnection.setNX(keySerializer.serialize(key), valueSerializer.serialize("0"));
    } finally {
        RedisConnectionUtils.releaseConnection(redisConnection, factory);
    }
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:15,代码来源:RedisHelper.java


示例5: getDataType

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
private String getDataType(String serverName, int dbIndex, String key) {
	RedisTemplate redisTemplate = RedisApplication.redisTemplatesMap.get(serverName);
	RedisConnection connection = RedisConnectionUtils.getConnection(redisTemplate.getConnectionFactory());
	connection.select(dbIndex);
	DataType dataType = connection.type(key.getBytes());
	connection.close();
	return dataType.name().toUpperCase();
}
 
开发者ID:mauersu,项目名称:redis-admin,代码行数:9,代码来源:RedisServiceImpl.java


示例6: getKV

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
private Object getKV(String serverName, int dbIndex, String key) {
	RedisTemplate redisTemplate = RedisApplication.redisTemplatesMap.get(serverName);
	RedisConnection connection = RedisConnectionUtils.getConnection(redisTemplate.getConnectionFactory());
	connection.select(dbIndex);
	DataType dataType = connection.type(key.getBytes());
	connection.close();
	Object values = null;
	switch(dataType) {
	case STRING:
		values = redisDao.getSTRING(serverName, dbIndex, key);
		break;
	case LIST:
		values = redisDao.getLIST(serverName, dbIndex, key);
		break;
	case SET:
		values = redisDao.getSET(serverName, dbIndex, key);
		break;
	case ZSET:
		values = redisDao.getZSET(serverName, dbIndex, key);
		break;
	case HASH:
		values = redisDao.getHASH(serverName, dbIndex, key);
		break;
	case NONE:
		//never be here
		values = null;
	}
	return values;
}
 
开发者ID:mauersu,项目名称:redis-admin,代码行数:30,代码来源:RedisServiceImpl.java


示例7: initRedisKeysCache

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
protected void initRedisKeysCache(RedisTemplate redisTemplate, String serverName , int dbIndex) {
	RedisConnection connection = RedisConnectionUtils.getConnection(redisTemplate.getConnectionFactory());
	connection.select(dbIndex);
	Set<byte[]> keysSet = connection.keys("*".getBytes());
	connection.close();
	List<RKey> tempList = new ArrayList<RKey>();
	ConvertUtil.convertByteToString(connection, keysSet, tempList);
	Collections.sort(tempList);
	CopyOnWriteArrayList<RKey> redisKeysList = new CopyOnWriteArrayList<RKey>(tempList);
	if(redisKeysList.size()>0) {
		redisKeysListMap.put(serverName+DEFAULT_SEPARATOR+dbIndex, redisKeysList);
	}
}
 
开发者ID:mauersu,项目名称:redis-admin,代码行数:14,代码来源:RedisApplication.java


示例8: doHealthCheck

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
	RedisConnection connection = RedisConnectionUtils
			.getConnection(this.redisConnectionFactory);
	try {
		Properties info = connection.info();
		builder.up().withDetail("version", info.getProperty("redis_version"));
	}
	finally {
		RedisConnectionUtils.releaseConnection(connection,
				this.redisConnectionFactory);
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:14,代码来源:RedisHealthIndicator.java


示例9: getCacheStatistics

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, RedisCache cache) {
    DefaultCacheStatistics statistics = new DefaultCacheStatistics();
    // @see http://redis.io/commands/INFO
    RedisConnection connection = RedisConnectionUtils.getConnection(this.redisConnectionFactory);
    try {
        Properties props = connection.info();
        Long hitCount = Long.parseLong(props.getProperty("keyspace_hits"));
        Long missCount = Long.parseLong(props.getProperty("keyspace_misses"));
        statistics.setGetCacheCounts(hitCount, missCount);
    } finally {
        RedisConnectionUtils.releaseConnection(connection, this.redisConnectionFactory);
    }
    return statistics;
}
 
开发者ID:fastnsilver,项目名称:xlator,代码行数:16,代码来源:RedisCacheStatisticsProvider.java


示例10: getRedisConnection

import org.springframework.data.redis.core.RedisConnectionUtils; //导入依赖的package包/类
@Override
public RedisConnection getRedisConnection() {
    return RedisConnectionUtils.getConnection(this.redisConnectionFactory);
}
 
开发者ID:eclipse,项目名称:keti,代码行数:5,代码来源:AbstractCacheHealthIndicator.java



注:本文中的org.springframework.data.redis.core.RedisConnectionUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultiPath类代码示例发布时间:2022-05-22
下一篇:
Java MySQLMaxValueIncrementer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap