如何开始使用Memcached

14
3个回答

17

好的,终于得到了答案...

我查看了超过50个与memcache相关的链接,唯一一个可以告诉你如何在项目中实现memcache的最佳链接是

http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=96698&av=163627

至于理论知识,请参考下面的链接

http://code.google.com/p/memcached/wiki/FAQ#What_is_the_maximum_data_size_you_can_store?_(1_megabyte)

代码示例为

http://www.koders.com/csharp/fid80DA3A5A619DF298A8902A3E74A94B7A126D0438.aspx?s=socket

我创建了一个小文档,在开始使用memcache之前请先查看。

        /// difference between set and add and replace

        /// add property do not use to add key which is already exist in memcache
        /// set use to overwite the key if that is already exist in memcache
        /// if key already exist ,replace property can replace it other wise not,where else set property use to replace if key already exist other wise it will add new key in the memcache


        ///Important
        ///
        /// if u are fetching the key which do not exist in memcache it will return null,as well if u are fetching the key whose value is null in memcache it will return null
        /// so avoid inserting the key with null value
        /// 
        ///If you simply want to avoid key collision between different types of data, simply prefix your key with a useful string. For example: "slash_1", "pradeep_1".  
        ///
        /// 
        /// 
        /// FlushAll() method use to remove(Flush) every thing from memcache
        /// 
        /// Stats() gives every information about the memcache like total items,connections,pId etc.....


        /// difference between increment, decrement
        /// 
        /// to use Increment or Decrement first u need to store counter by StoreCounter method else u will get null
        ///


        /// difference between GetMultiple and GetMultipleArray
        /// 
        ///GetMultiple gives you the object with there key and GetMultipleArray gives you the object not the key

12

你需要一个Memcache服务器和一个Memcache客户端。

我发现Windows平台上最好的Memcache服务器之一是http://www.membase.com/products-and-services/memcached

它是由原始的Memcached开发人员构建的。安装只需几分钟,通过他们的Web界面进行配置非常容易。

推荐的.NET Memcache客户端是Enyim http://memcached.enyim.com/

你可以在https://github.com/enyim/EnyimMemcached/wiki找到Enyim的配置示例。

另外,我实际上发现Microsoft AppFabric Caching(代号Velocity)在.NET上工作得更好。我在使用Memcache和Linq对象时遇到了序列化问题,但AppFabric却没有问题。

如果您对AppFabric也感兴趣,这里有一个关于AppFabric的教程:

http://www.hanselman.com/blog/InstallingConfiguringAndUsingWindowsServerAppFabricAndTheVelocityMemoryCacheIn10Minutes.aspx


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接