I have a farm of servers, each server is regularly making an identical query to the database. These query results are cached in a shared cache, accessible to all servers.
How can I ensure that a newer query does not get overwritten by an older query? Is there a way of versioning the queries somehow, by time for example, so that this doesn't happen? How to deal with concurrent queries?
Thanks!
Edit: db is SQL Server. Query is a select statement. And, caching mechanism is very simple: simple write, with no locking. And that is because there is currently no way of telling the order of the select queries.