5

如题。无论如何,我没有通过谷歌找到一个。

更新:感谢两个答案的链接;这非常有用,但不是我想要的——我很想知道是否可以查询由 RDBMS 支持的 memcached(或其他一些分布式缓存)支持的 IRepository。我真的不知道这在实践中如何运作。我不太了解分布式缓存或 LINQ 提供程序的内部结构。

我可能正在设想类似于缓存 LINQ 提供程序根据查询自动生成缓存键(其中查询可以是 Expression> 或某种规范模式实现),并且基本上可以在我的应用程序和我的数据库之间进行填充。听起来有用吗?

4

4 回答 4

1

如果您不介意在它们之间使用NHibernate,您可以使用LINQ to NHibernate来查询可以设置为使用memcached作为缓存的实体。

于 2008-10-27T21:53:12.373 回答
1

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;
    }
}
于 2008-12-09T08:00:59.407 回答
1

因为我不知道 memcached 是什么,所以我四处搜索并找到了这个链接:

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

其中在底部附近有一个关于在 memcached 上使用 LINQ 查询的部分。

于 2008-12-09T08:11:01.977 回答
0

我也遇到了一些用于 memcached 的 linq 问题。但是您应该检查 linq DBML 的序列化是否是单向的。

您可能对这个解决方案很幸运,值得一试。对我来说,我对 linq 有问题,但其他具有 [Serilizable] 属性的对象工作正常。

于 2010-01-23T03:49:33.200 回答