import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.ShardedJedisPool;
public class RedisUtils {
private static JedisPool pool;
static {
ResourceBundle bundle = ResourceBundle.getBundle("properties/redis");
if (bundle == null) {
throw new IllegalArgumentException(
"[redis.properties] is not found!");
}
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxActive(Integer.valueOf(bundle
.getString("redis.pool.maxActive")));
config.setMaxIdle(Integer.valueOf(bundle
.getString("redis.pool.maxIdle")));
config.setMaxWait(Long.valueOf(bundle.getString("redis.pool.maxWait")));
config.setTestOnBorrow(Boolean.valueOf(bundle
.getString("redis.pool.testOnBorrow")));
config.setTestOnReturn(Boolean.valueOf(bundle
.getString("redis.pool.testOnReturn")));
pool = new JedisPool(config, bundle.getString("redis.ip1"),
Integer.valueOf(bundle.getString("redis.port")));
}
private ShardedJedisPool shardedJedisPool;
private Jedis jedis;
public void setPool(JedisPool pool) {
this.pool = pool;
}
public void setShardedJedisPool(ShardedJedisPool shardedJedisPool) {
this.shardedJedisPool = shardedJedisPool;
}
public void setJedis(Jedis jedis) {
this.jedis = jedis;
}
public String setString(String key, String value) {
Jedis jedis = pool.getResource();
try {
return jedis.set(key, value);
} finally {
pool.returnResource(jedis);
}
}
相关推荐
Spring Data Redis简介 可以在这里找到详细的描述:
redis-sample:Spring Boot Redis테스테스트
源文件格式key,value ==》 经过处理后*3$3set$3key$5value 使用方式LANG=C ./sample.awk test.csv | redis-cli --pipe -h 127.0.0.1 -p 6379
sparkline.c 一个拥有sample列表的序列 t_hash.c hash在Server/Client中的应答操作。主要通过redisObject进行类型转换。 t_list.c list在Server/Client中的应答操作。主要通过redisObject进行类型转换。 t_set.c set...
commands in easy-to-understand examples, and then uses Redis in a few sample applications, with Redis as the backbone. The later sections of the book focus on the management of Redis for performance ...
App42PaaS-Node-Redis-Sample 用于 App42 PaaS 平台的带有 Redis 的示例节点应用程序开始使用 App42 为所需环境设置基础设施创建服务部署 Node 应用程序为所需环境设置基础设施 $ app42 setupInfra 创建服务 $ app42...
Python Redis # pip install -i http://pypi.douban.com/simple redis RQ # pip install -i http://pypi.douban.com/simple rq Redis Server # docker pull redis:latest # docker run -d -p 6379:6379 -t redis:...
spring boot 集成 redis 的例子
安装redis集群管理器 mkdir /var/log/codis -pv cd /workspace/Go/src/github....
该示例演示了如何为Python + Redis项目设置DaoCloud CI。
使用 Finagle Redis 客户端的示例应用程序要运行示例,请在默认端口 (6379) 上本地启动 Redis,然后执行: cd finagle-redis-samplesbt run享受 !! (是) :)
Redis Cloud Java示例在框架上运行的Java应用程序示例,演示了如何在Heroku中使用 。 并密钥,获取Redis并数据库。 该应用程序当前在Heroku上运行: ,并使用作为后端。部署到Heroku 立即将其部署到Heroku:
finagle-redis-master-slave-sample 用于 Finagle 的简单自定义 Redis 客户端,具有手动负载平衡。 为了运行示例,需要在 :6379 上使用本地 Redis,并且代码应该能够查询正确的服务器。 当然,完整的 Redis 主/从...
您可以查看config.sample.yml以获取示例配置。 请注意,某些选项彼此不兼容,例如,您不能在 GET 请求中发送请求正文。 除非您正在处理 phoenix 本身,否则不要编辑 default.yml。注射通过在 config.yml 中设置js键...
使用 Redis 作为标记缓存和分布式锁管理器的示例代码。 用法 运行DistributedLockingPerMethod控制台应用程序的多个实例,以查看 Redis 作为分布式锁管理器的模拟。 检查RedisWithTaggingAndLockingTests 中的测试并...
npm i redis-writable const toWritable = require ( 'redis-writable' ) ; console . log ( toWritable ( 'SET' , [ 'foo' , 'bar' ] ) ) ; // *3 // $3 // SET // $3 // foo // $3 // bar 基准测试 Platform info...
springboot 技术用例,介绍springboot 如何集成activemq、redis、schedule、resutful、profiles等用例。
Azure Redis缓存示例 此存储库包含Azure Redis缓存服务的WPF客户端的源代码,用于在发布-订阅模型中进行聊天演示。 我们的项目当前包含一个WPF应用程序,该服务具有StackExchange.Redis包作为服务,使我们能够连接...
- 文中涉及的例子源码网址: https://gitee.com/topfox/topfox-sample - TopFox技术交流群 QQ: 874732179 ## 1.2. topfox 介绍 在 srpingboot2.x.x 和MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。...
AspNetCoreHighConcurrency.Sample AspNetCore高并发示例代码。描述如何使用基于Redis的分布式锁定。 无锁和排队的商品库存操作。 分为三个例子 1.基于redis的分布式锁 2,基于Redis的原子操作使用lua脚本 3,基于...