代码之家  ›  专栏  ›  技术社区  ›  Peter Mounce

有人知道有人在开发linq to memcached提供程序吗?

  •  5
  • Peter Mounce  · 技术社区  · 17 年前

    作为头衔。无论如何,我没有通过谷歌找到。

    更新:感谢来自两个答案的链接;这非常有用,但不是我想要的-我很好奇是否可以查询一个由memcached(或其他一些分布式缓存)支持、由rdbms支持的irepository。我真的不知道这在实践中是如何工作的;我不太了解分布式缓存或linq提供程序的内部。

    我可能正在设想一个类似cache-linq提供者的东西,它根据查询自动生成缓存密钥(其中查询可以是expression>或某种规范模式实现),基本上可以放在我的应用程序和数据库之间。听起来有用吗?

    4 回复  |  直到 17 年前
        1
  •  1
  •   wprl    17 年前

    如果你不介意的话 NHibernate 在他们之间,你可以使用 LINQ to NHibernate 查询实体 can be set 使用 memcached 作为他们的藏身之处。

        2
  •  1
  •   Funky81    17 年前

    我不知道如果这是你想要的,你可以签这个 website 是的。在这里,您可以查询memcached以及查询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");  
       }  
    

    这就是你想要的吗?

    这是源代码

    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;
        }
    }
    
        3
  •  1
  •   Cameron MacFarland    17 年前

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

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

    在底部有一个关于在memcached上使用linq查询的部分。

        4
  •  0
  •   DucDigital    16 年前

    我也遇到了一些关于linq for memcached的问题。但是不管linq dbml是不是单向的,都应该检查它的序列化。

    你也许有这个解决方案的运气,值得一试。对我来说,我可能对linq有问题,但其他具有[可序列化]属性的对象可以正常工作。