We are facing an issue where some API calls (connecting to our redis DB) are slow during the time there is decline in number of redis keys. We suspect these are due to expiry or eviction. We need to find out any logs which show the logs for this action and if possible which alogorithm i.e. KEYS,SCAN etc. was used to trigger this Eviction/Expiry
A couple of questions and some observations so that we can better help you figure this one out:
Assuming you are using Redis as your cache, what framework/language are you using and how is the cache configured?
You are right that it is likely the TTL (time to live) of the keys being cached. Find out what the TTL is for new cache entries (see TTL | Redis)
One quick way to find out what the TTL is would to use the Redis CLI and issue a TTL mykey for one of the keys in the cache
Is your Redis instance configured to persist the data to disk? If so, is it RDB or AOF?
if not, check if your company has a policy to bounce/restart machines on a schedule. If your cache is not persistent that would produce 100% misses after a server restart
Also, depending on how you are creating those keys you might be getting cache misses for queries/API calls that you should be hits