Spring Redis Delete does not delete key
An alternative technique for deleting using ValueOperations
is to set an empty value that will expire almost immediately. Redis will handle the eviction itself.
For example, you can set a value like this:
valueOperations.set("key", "value");
When you want to delete you can then do something like this:
valueOperations.set("key", "", 1, TimeUnit.MILLISECONDS);
It's essential that the key is the same in both operations
Try this:
public void deleteCustomer(BigInteger id) { redisTemplate.execute(new RedisCallback<String>() { @Override public String doInRedis(RedisConnection redisConnection) throws DataAccessException { redisConnection.del(redisTemplate.getStringSerializer().serialize(String.valueOf(id))); return null; } });}