I am trying to delete a redis key but for some reason it is not delete but also not throwing an exception. Here is my code to delete:
import com.example.service.CustomerService;
import com.example.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigInteger;
import java.util.*;
@Service
public class RedisCustomerService implements CustomerService {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
private String uniqueIdKey = "customerId";
private BigInteger uniqueId() {
long uniqueId = this.redisTemplate.opsForValue().increment(uniqueIdKey, 1);
return BigInteger.valueOf(uniqueId);
}
private String lastNameKey(BigInteger id) {
return "customer:ln:" + id;
}
private String firstNameKey(BigInteger id) {
return "customer:fn:" + id;
}
@Override
public void deleteCustomer(BigInteger id) {
redisTemplate.opsForValue().getOperations().delete(String.valueOf(id));
}
}