Debugging Cache Entries

Debugging Cache Entries

Overview

This document details steps for accessing the dev stack’s Elasticache, using an EC2 instance (created by @tschetan) and Redis queries

Steps for connecting

  1. Log into the firefly-music-dev AWS account and navigate to the EC2 console

  2. Find the cache_debug instance -> Click Connect -> Select the Session Manager tab

  3. Once viewing the command prompt, run sudo -i

  4. cd redis-stable/src to navigate to the correct folder

  5. ./redis-cli -h clustered-general-dev-0001-001.rt1ypq.0001.use1.cache.amazonaws.com -c

    1. The cluster should be taken from Elasticache console in same region and excluding port at end (ex: :6769)

    2. You may need to try all endpoints for a cluster to find the actual value you’re searching for, as entries are hashed across instances

Accessing the data

You should now have direct access to a cache, and can run one of the following commands based on your use case

keys *

This lists all keys in the cluster. Instead of the *, you can do *AHFDD* to get specific customer id or *DMPBrowse.Categories* to get specific cache values

get key

This will retrieve the actual value for a key obtained above

del key

This will remove a value from the cache (be careful with the wildcard you use!)

If you don’t see the entries you expect

  1. Check the other endpoints in the Elasticache cluster, as a cache entry may exist in any of them

  2. Try using a different wildcard (*, customerId, API) for the search

  3. Check the TTL for the entry you are checking, as it may be deleting quickly, or your code may not be being hit due to a pre-existing cache value

  4. Make sure you are using the Elasticache endpoint for the correct region