Supported Libraries
Supported Operations
Operation | Methods Supported |
---|
Insert | - redis.clients.jedis.Jedis.lpush
- redis.clients.jedis.Jedis.rpush
- redis.clients.jedis.Jedis.hmset
- redis.clients.jedis.Jedis.sadd
- redis.clients.jedis.Jedis.zadd
- redis.clients.jedis.Jedis.hset
- redis.clients.jedis.Jedis.set
- redis.clients.jedis.JedisCommands.expire
- redis.clients.jedis.JedisCommands.pexpire
- redis.clients.jedis.JedisCommands.expireat
- redis.clients.jedis.JedisCommands.pexpireat
- redis.clients.jedis.JedisCommands.setrange
- redis.clients.jedis.JedisCommands.set
|
Select | - redis.clients.jedis.Jedis.lrange
- redis.clients.jedis.Jedis.smembers
- redis.clients.jedis.Jedis.zscore
- redis.clients.jedis.Jedis.zrevrange
- redis.clients.jedis.Jedis.hget
- redis.clients.jedis.Jedis.hgetAll
- redis.clients.jedis.Jedis.keys
- redis.clients.jedis.Jedis.get
- redis.clients.jedis.JedisCommands.zadd
- redis.clients.jedis.JedisCommands.get
- redis.clients.jedis.JedisCommands.ttl
- redis.clients.jedis.JedisCommands.getrange
- redis.clients.jedis.JedisCommands.pttl
- redis.clients.jedis.Transaction.exec
|
Delete | - redis.clients.jedis.Jedis.del
- redis.clients.jedis.Jedis.lrem
- redis.clients.jedis.Jedis.lpop
- redis.clients.jedis.Jedis.rpop
- redis.clients.jedis.Jedis.srem
- redis.clients.jedis.Jedis.spop
- redis.clients.jedis.Jedis.zrem
|
Objects
Icon | Description |
---|
| Java Redis Connection |
| Java Redis Collection |
| Java unknown Redis Connection |
| Java Unknown Redis Collection |
Links
Links are created for transaction and function point needs:
Link type | When is this created? | Methods Supported |
---|
belongsTo | From Redis collection object to Redis connection object |
|
useSelectLink | Between the caller Java method object and Redis collection object
| - lrange
- smembers
- zscore
- zrevrange
- hget
- hgetAll
- keys
- get
|
useInsertLink | - lpush
- rpush
- hmset
- sadd
- zadd
- hset
- set
|
useDeleteLink | - del
- lrem
- lpop
- rpop
- srem
- spop
- zrem
|
What results can you expect?
Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.
Redis Connection
Redis connection
public class RedisService {
public static String server = "localhost";
public Boolean addEmployee(Employee employee) {
Jedis jedis = new Jedis(server);
}
# for unknown
public void addDeptInfo(String key, String data) {
Jedis jedis = new Jedis(RedisProperties.connection);
jedis.set(key, data);
}
}

Insert Operation
Insert Operation for various Redis Collections
//adding employee in a redis list
public Boolean addEmployee(Employee employee) {
Jedis jedis = new Jedis(server);
Employee emp = new Employee();
emp=getEmployee(employee.getEmployeeId());
jedis.lpush("employeelist", employee.toString());
return true;
}
//add departments in a set
public void addDept(String dept) {
Jedis jedis = new Jedis(server);
jedis.sadd("departments", dept);
}

Select Operation
Select Operation for various Redis Collections
//get all employees from employee list
public List<Employee> getAllEmployee(){
List<Employee> employeeList = new ArrayList<>();
Jedis jedis = new Jedis(server);
List<String> employees = jedis.lrange("employeelist", 0, jedis.llen("employeelist"));
for (String employee: employees) {
String[] emp1=employee.split(",");
Employee emp = new Employee(Integer.parseInt(emp1[0]), emp1[1], emp1[2]);
employeeList.add(emp);
}
return employeeList;
}
//get all departments from set
public Set<String> getDepts() {
Jedis jedis = new Jedis(server);
return jedis.smembers("departments");
}

Delete Operation
Delete Operation for various Redis Collections
// delete first visitor from visitors set
public Visitor deleteVisitor() {
Jedis jedis = new Jedis(server);
Map<String,Integer> visitors = get_Visitors();
Visitor vis = new Visitor();
for (Map.Entry<String, Integer> visitor : visitors.entrySet()) {
vis.setName(visitor.getKey());
vis.setId(jedis.zscore("visitors", visitor.getKey()));
break;
}
jedis.zrem("visitors", vis.getName());
return vis;
}
//delete department information from cache
public String deleteDeptInfo(String key) {
Jedis jedis = new Jedis(server);
String value = jedis.get(key);
jedis.del(key);
return key + " = " + value + " successfully deleted";
}

Jedis Commands
Command operations
public void addActiveNum(Integer userId,double score){
int month = DateUtil.thisMonth()+1;
String key = CommonConstant.FQ_ACTIVE_USER_SORT+month;
try {
JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
Double scoreStore = commands.zscore(key,userId.toString());
if(scoreStore == null){
scoreStore = score;
}else {
scoreStore += score;
}
commands.zadd(key,scoreStore,userId.toString());
commands.expire(key,180*24*60*60);
} catch (Exception e) {
logger.error(e);
}finally {
JedisProviderFactory.getJedisProvider(null).release();
}
}

public static void refreshUserCacheByUid(Integer userId){
String cacheKey = "FqUser.id:"+userId;
try {
JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
FqUserService fqUserService = SpringUtils.getBean("fqUserServiceImpl");
FqUser fqUser = fqUserService.selectByPrimaryKey(userId);
FqUserCache fqUserCache = new FqUserCache(fqUser);
commands.set(cacheKey,JSON.toJSONString(fqUserCache));
commands.expire(cacheKey,300);
} catch (Exception e) {
logger.error("refreshUserCacheByUid",e);
}finally {
JedisProviderFactory.getJedisProvider(null).release();
}

public void remove(final String key, final String... member){
return exec(new RedisCallback<Long>() {
@Override
public Long doCallback(JedisCommands commands) {
return commands.zrem(key, member);
}
});
}

Evolution
- Resolution increased for Redis Connection and collection objects
- Crud operation support for Jedis commands and transactions
Future Development
- Support for package redis.clients.jedis.params