I am in the process of implementing a cache system for a series of apps that access an external (as not under our control) API via XML queries. The API is slowing down during peak hours and we have a number of clients that complained about this.
I plan on using Symfony/Cache with the filesystem adapter (and later with Redis). The approach I want to take is to store a hash of the query as the Cache Item Key, and the API response as the cache value.
So every time a user tries to make a call to the API, the app will generate the hash of the query and search for it in the cache. If there's a hit (found and not expired) it will return the cached response, otherwise it will call the API and store the response in the cache.
What hashing algorithm should I use in order to not have any collisions (we don't want the client to get the wrong response) and also be fast enough?