Причината за изключението вероятно е, че реализацията на шаблона Spring не използва повторно същата връзка за .multi() и .exec() . Можете да опитате да използвате execute() чрез обратно повикване:
private RedisTemplate template = ...;
template.execute(
new RedisCallback() {
@Override
public Object doInRedis(RedisConnection connection)
throws DataAccessException {
connection.multi();
//do whatever you need, like deleting and repopulating some keys
connection.expire(CHANNEL_KEY.getBytes(), EXPIRE_SECS);
connection.exec();
return null;
}
}
);