I would like to expose a few endpoints via a WCF data service (Singlton) which will maintain a collection of data used to respond to individual requests.
Ideally I would like to be able to expire (delete) the data held in memory for a given request after a period of time.
The stored data would be used to build (partially only, so out of the box caching is not ok) a result set to return to the client. The data will be objects from an API and must be kept in memory, not peristed to storage.
I’m looking for ways to trigger the ‘purge’ process to check for expired data. Kicking off a timer in the ctor seems like a bad idea. It could be run for every request (single concurrency in enabled) but this seems excessive, and would potentially leave data hanging around when there are not more requests?
Any thoughts at all on the issue appreciated.
Ended up redesigning and hosting the relevant service component in a windows service with a system timer to purge required data.