I dont if this is what you want, you can check in this website. In there you can query Memcached as well as query linq to object.
public static IEnumerable<User> GetAllUsers()
{
// Retrieve from cache if it exists, otherwise run the query
return (from u in ctx.Users select u).CachedQuery("allusers");
}
Is this what you want ?
Here is the source code
public static IEnumerable<T> CachedQuery<T>
(this IQueryable<T> query, string key) where T : class
{
if (cache.KeyExists(key))
{
return (IEnumerable<T>)cache.Get(key);
}
else
{
IEnumerable<T> items = query.ToList();
cache.Set(key, items);
return items;
}
}