Peter Mounce
Peter Mounce

Reputation: 4225

Does anyone know of anyone working on a LINQ-to-Memcached provider?

As title. I didn't find one via google, at any rate.

Update: thanks for the links from the two answers; this is very useful, but not what I was after - I am curious to see whether it is possible to query an IRepository backed by memcached (or some other distributed cache), backed by a RDBMS. I've really no idea how that might work in practise; I don't know very much about the internals of either distributed caches or LINQ providers.

I'm maybe envisaging something like the cache LINQ provider generating cache-keys based on the query automatically (where query could be Expression> or some kind of Specification pattern implementation), and basically can be plumped down inbetween my app and my DB. Does that sound useful?

Upvotes: 5

Views: 1110

Answers (4)

DucDigital
DucDigital

Reputation: 4622

I encounter some problem with linq for memcached also. But you should check out the serialization of your linq DBML whether it's Unidirectional or not.

you might have luck for this solution, worth to try out. For me, i sitll having problem with linq, but other object that have [Serilizable] attribute works fine.

Upvotes: 0

Cameron MacFarland
Cameron MacFarland

Reputation: 71956

Because I didn't know what memcached is I googled around and found this link:

http://latebound.blogspot.com/2008/10/using-memcached-from-c.html

Which has a section near the bottom on using LINQ queries over memcached.

Upvotes: 1

Funky81
Funky81

Reputation: 1677

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;
    }
}

Upvotes: 1

wprl
wprl

Reputation: 25447

If you don't mind throwing NHibernate between them, you can use LINQ to NHibernate to query entities which can be set to use memcached as their cache.

Upvotes: 1

Related Questions