The latest release of EPiServer Find contains, apart for a number of bug fixes, one new feature and that is the ability to set a time to live-value on indexed documents. The value is expressed as a TimeSpan and specifies how long the document should reside in the index before it is automatically deleted. This can be really useful if you index documents continuously (say that you index all items that users currently are looking at on your site) but only what to show the latest (i.e. what users are currently looking at on the site) and don’t want to flood your index over time (i.e I don’t care what someone looked at yesterday). Under these circumstances the time to live-feature can really help you by doing that dirty cleanup job that we all hate to to do.
How to use time to live
Given an object with a TimeToLive property (or TimeSpan):
We first need to configure the client and register the TimeToLive-property for the given object type:
When indexing an object we simply register a TimeSpan value to the property specifying how long it should reside in the index:
I hope you may find this useful when making your site awesome with EPiServer Find!
The granularity of time to live is 60 seconds meaning that the documents will be deleted within 60 seconds of the actual time to live.
Instead of configuring the TimeToLive-property by the conventions it can be annotated by the TimeToLiveAttribute:
or passed in the index call: