Trying to implement prompt caching using MongoDBCache in my RAG based document answering system but facing an issue

Hey guys!
I am working on a multimodal rag for complex pdfs (using a pdf rag chain) but i am facing an issue. I am trying to implement prompt caching using Langchain's MongoDBCache in my RAG based document answering system.

I had created a post on this issue few days ago but i didn't get any replies due to lack of enough description of the problem.

https://preview.redd.it/rfbkmsvkq5he1.png?width=742&format=png&auto=webp&s=62365bec51d4d5a31b9d646268a00557ef11bbbe

The problem i am facing is that the query that i ask is getting stored into the MongoDBCache but, when i ask that same query again, MongoDBcache is not being used to return the response.

For example look at the screenshots: i said "hello". That query and response got stored into the cache ( in second screenshot ) , but when i send "hello" one more time, i get a unique response, different from the previous one. Ideally it should be same as previous one as the previous query and its response was cached. But that doesn't happen, instead the second "hello" query also gets cached with a unique ID.

cached responses

Note: MongoDBCache is different from Semantic Cache

code snippet:

https://preview.redd.it/xvmgzwgot5he1.png?width=835&format=png&auto=webp&s=d2c285e3fae7930ba4bb13fcdeb5c1b13423b325

https://preview.redd.it/vfv8eowqt5he1.png?width=796&format=png&auto=webp&s=0750cde4a4b7a47bc6cc35e5c2ef206a8e16a3b6