I have a very large ASP.Net C# ver 4.8 solution with several projects. The application uses Redis as remote cache. I want to audit the code on regular basis (once a quarter) to get full list of all redis keys. Once I have baseline after initial run, I want to compare and see any recently added keys etc.
Code interacts with Redis through an abstracted layer, CacheManager. Some typical calls looks like this.
cacheManager.Set("key1", "value1")
myCache.Get("key1")
cache.Set("key2", "value2");
Where cacheManager, myCache, cache etc. are local instances of CacheManager.
I want to get a full list of CacheManager usage along with keys and values. Should I look into Static Code Analysis options or something else?
You can approach this from two sides. If you want to find all set methods from your Cache Manager, right click the class name and select Find all references (Ctrl + K, R by default). Then go through that list and check all keys.
If the redis instance is only used by this application, you could very wsell open up the
redis-cliand output all keys to a txt file and analyse it this way. Might also be faster.If all your keys are prefixed you can of course adapt the query to
keys prefix:*or whatever. The asterisk is the wildcard.