项目作者: yhqy

项目描述 :
simple redis util, support singleton, sentinel
高级语言: Java
项目地址: git://github.com/yhqy/simple-redis-util.git
创建时间: 2019-04-26T07:06:06Z
项目社区:https://github.com/yhqy/simple-redis-util

开源协议:MIT License

下载


simple-redis-util

simple redis util, support singleton, sentinel server

how to config/init ?

  1. //init, do not do it more than once !
  2. //if password is empty, use null replace!
  3. //singleton
  4. RedisUtils.init("localhost:6379", password, 6);
  5. //sentinel
  6. RedisUtils.init("192.168.1.200:27380,192.168.1.200:27381,192.168.1.200:27382","secret", 0, 10000, "redis7380");

how to use ?

  1. //store value, value can be any object
  2. RedisUtils.set(key,value);
  3. //query value, auto convert to tclass
  4. T t = RedisUtils.get(key, tclass);
  5. //delete key
  6. RedisUtils.del(key);
  7. //query keys by keyPattern
  8. Set<String> keys = RedisUtils.keys(keyPattern);

use case

  1. see RedisUtilsTest.java