London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Navigation [hide] [expand]
Area: Optimizely Search & Navigation
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Introduction

Search request can be cached using a certain duration using the StaticallyCacheFor method which accepts a timespan. No cache key is required as that will be automatically generated from the search request.

Examples

The code below will either return a previously cached result or execute the query and cache the result for five minutes.

C#
var result = client.Search<BlogPost>()
    .StaticallyCacheFor(TimeSpan.FromMinutes(5))
    .GetResult();

It is also possible to cache results with a dependency (System.Web.Caching.Dependency) using an overload to the StaticallyCacheFor method.

Last updated: Jun 10, 2014