@anuvakkachen noticed:
There's something I wanted to ask you about this. I noticed that the cache is trimmed only when there's a cache hit. I was wondering whether this is the intended behavior of this cache. It so happens that when I have several consecutive cache misses ,the cache gets full and grows beyond max size until there's a cache hit where upon everything gets trimmed. I might have missed something . Looking forward to hearing from you about this.