【发布时间】:2011-01-31 06:29:24
【问题描述】:
目前我正在做一个需要使用 memcached 的项目。我研究了很多网络链接,但我不明白如何开始使用 memcached。我已经使用过 mongodb,但希望获得有关配置 memcached 的帮助。
我使用的是windows 7操作系统,目前使用过以下链接。
http://www.codeforest.net/how-to-install-memcached-on-windows-machine
【问题讨论】:
目前我正在做一个需要使用 memcached 的项目。我研究了很多网络链接,但我不明白如何开始使用 memcached。我已经使用过 mongodb,但希望获得有关配置 memcached 的帮助。
我使用的是windows 7操作系统,目前使用过以下链接。
http://www.codeforest.net/how-to-install-memcached-on-windows-machine
【问题讨论】:
嗯,终于知道答案了……
我已经浏览了 50 多个与 memcache 相关的链接,最好的也是唯一的链接,可以告诉你如何在你的项目中实现 memcache
http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=96698&av=163627
理论知识请参考以下链接
代码示例是
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
【讨论】:
您将需要一个 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 缓存(代号为 Velocity)更适合 .NET。我遇到了 Memcache 和 Linq 对象的序列化问题,而 AppFabric 工作没有问题。
如果您也对 AppFabric 感兴趣,这里有一个关于 AppFabric 的教程
【讨论】:
根据此处的一些安装信息,他们似乎希望您在类似 unix/linux 的操作系统上运行:http://code.google.com/p/memcached/wiki/NewInstallFromPackage
您也可以将 linux 安装到虚拟机中(试试 VirtualBox,它的免费 http://www.virtualbox.org/)并尝试这种方式。
它看起来确实有 Windows 的端口:http://code.google.com/p/memcached/wiki/PlatformWindows
安装的特定部分是否不适合您?
【讨论】: