Let say for example I have the following code:
return (long) redisTemplate.execute(new RedisCallback() {
@Override
public Object doInRedis(RedisConnection connection) throws DataAccessException {
String redisKey = RedisKeyUtil.getDAUKey(df.format(start), df.format(end));
connection.bitOp(RedisStringCommands.BitOperation.OR,
redisKey.getBytes(), keyList.toArray(new byte[0][0]));
return connection.bitCount(redisKey.getBytes());
}
});
Will this doInredis method be executed in the redis cluster and not in my program?
2
Answers
You’re Java code will not run in Redis. Redis doesn’t even know about the JVM so it can’t do that at all.
No.
RedisTemplate
is just a Springboot helper class that simplifies your Redis data access code, and it is still executing locally in your thread.If your use case is all related to basic Redis command, you can use Lua (example code here). However, there is not prefix filtering in list operation, so you probably can also try
CompletableFuture
so your data processing won’t block other operations.