[转]Installing Memcached on Windows

Installing Memcached on Windows

Memcached is a high performance, in-memory key-value store or caching system. Its main purpose is to speed up web applications by caching database queries, contents, or other computed results.

Memcached is originally a linux application, but since it is open-source, it has been compiled for windows. There are two major sources for the pre-built windows binary: Jellycan and Northscale, and both versions can be used. The following are the download links for the memcached windows binaries:

http://code.jellycan.com/files/memcached-1.2.5-win32-bin.zip
http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip
http://downloads.northscale.com/memcached-win32-1.4.4-14.zip
http://downloads.northscale.com/memcached-win64-1.4.4-14.zip
http://downloads.northscale.com/memcached-1.4.5-x86.zip
http://downloads.northscale.com/memcached-1.4.5-amd64.zip

In versions earlier than 1.4.5, memcached can install itself as a service. However, the ability to run memcached as a service is removed since version 1.4.5. Therefore, the installation steps are divided into two categories, part A for memcached prior to version 1.4.5. and part B for memcached version 1.4.5 and later.

A) Installation of memcached < 1.4.5:

  1. Extract the memcached windows binary to any directory.
  2. In versions earlier than 1.4.5, memcached can install itself as a service. Run a command prompt with elevated privileges, and type:
    c:\memcached\memcached.exe -d install

    * Replace c:\memcached\memcached.exe with the actual path of your installation.

  3. Then, start or stop the memcached service with the following command:
    c:\memcached\memcached.exe -d start
    c:\memcached\memcached.exe -d stop
  4. To change the configuration of memcached, run regedit.exe and navigate to the key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached". Suppose you wish to increase the memory limit of memcached, edit the value of ImagePath to the following:
    "c:\memcached\memcached.exe" -d runservice -m 512

    * Besides '-m 512', you may also append other memcached parameters to the path. Run "c:\memcached\memcached.exe -h" to view the list of available parameters.

  5. Meanwhile, to uninstall the memcached serivce, run the following command:
    c:\memcached\memcached.exe -d uninstall

B) Installation of memcached >= 1.4.5:

  1. Extract the memcached windows binary to any directory.
  2. In version 1.4.5 or later, memcached cannot run as a service. It must be started as a normal process using the task scheduler. To configure the memcached process to run automatically every time windows start, run a command prompt with elevated privileges, and type the following:
    schtasks /create /sc onstart /tn memcached /tr "'c:\memcached\memcached.exe' -m 512"

    * Replace c:\memcached\memcached.exe with the actual path of your installation.
    ** Besides '-m 512', you may also append other memcached parameters to the path. Run "c:\memcached\memcached.exe -h" to view the list of available parameters.

  3. Meanwhile, to remove the scheduled memcached task, run the following command:
    schtasks /delete /tn memcached

 

Integrating with PHP

To interface with memcached in PHP, you need to install the memcache extension for PHP:

  1. Check that your PHP extension folder has the file php_memcache.dll. If not, download the file from https://pecl.php.net/package/memcache (select the windows dll file), and place it in the PHP extension folder.
  2. Add the following line in php.ini to enable the memcache extension.
    extension=php_memcache.dll
  3. Create this simple php script file to test that it works.
    <?php$memcache = new Memcache;
    $memcache->connect('localhost', 11211) or die ("Could not connect");$version = $memcache->getVersion();
    echo "Server's version: ".$version."<br/>\n";$tmp_object = new stdClass;
    $tmp_object->str_attr = 'test';
    $tmp_object->int_attr = 123;$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
    echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";$get_result = $memcache->get('key');
    echo "Data from the cache:<br/>\n";var_dump($get_result);?> 

Integrating with Python

To interface with memcached in Python, you need to install the memcached client for Python.

  1. Execute one of the following command to install the memcached client. The first is for Python 2.x while the second is for Python 3.x.
    pip install python-memcached
    pip install python3-memcached
  2. Create this simple python script to test that it works.
    import memcache
    mc = memcache.Client(['127.0.0.1:11211'], debug=0)
    mc.set("some_key", "Some value")
    value = mc.get("some_key")
    mc.set("another_key", 3)
    mc.delete("another_key")
    mc.set("key", "1")   # note that the key used for incr/decr must be a string.
    mc.incr("key")
    mc.decr("key")

Memcached statistics

To view the statistics for memcached, bring up a telnet connection to memcached by the command:

telnet 127.0.0.1 11211

Then, type stats and enter.

Here is an explanation of the different memcached stats.

NameTypeMeaning
NameTypeMeaning
pid32uProcess id of this server process
uptime32uNumber of secs since the server started
time32ucurrent UNIX time according to the server
versionstringVersion string of this server
pointer_size32Default size of pointers on the host OS (generally 32 or 64)
rusage_user32u.32uAccumulated user time for this process (seconds:microseconds)
rusage_system32u.32uAccumulated system time for this process (seconds:microseconds)
curr_items32uCurrent number of items stored
total_items32uTotal number of items stored since the server started
bytes64uCurrent number of bytes used to store items
curr_connections32uNumber of open connections
total_connections32uTotal number of connections opened since the server started running
connection_structures32uNumber of connection structures allocated by the server
reserved_fds32uNumber of misc fds used internally
cmd_get64uCumulative number of retrieval reqs
cmd_set64uCumulative number of storage reqs
cmd_flush64uCumulative number of flush reqs
cmd_touch64uCumulative number of touch reqs
get_hits64uNumber of keys that have been requested and found present
get_misses64uNumber of items that have been requested and not found
delete_misses64uNumber of deletions reqs for missing keys
delete_hits64uNumber of deletion reqs resulting in an item being removed.
incr_misses64uNumber of incr reqs against missing keys.
incr_hits64uNumber of successful incr reqs.
decr_misses64uNumber of decr reqs against missing keys.
decr_hits64uNumber of successful decr reqs.
cas_misses64uNumber of CAS reqs against missing keys.
cas_hits64uNumber of successful CAS reqs.
cas_badval64uNumber of CAS reqs for which a key was found, but the CAS value did not match.
touch_hits64uNumer of keys that have been touched with a new expiration time
touch_misses64uNumer of items that have been touched and not found
auth_cmds64uNumber of authentication commands handled, success or failure.
auth_errors64uNumber of failed authentications.
evictions64uNumber of valid items removed from cache to free memory for new items
reclaimed64uNumber of times an entry was stored using memory from an expired entry
bytes_read64uTotal number of bytes read by this server from network
bytes_written64uTotal number of bytes sent by this server to network
limit_maxbytes32uNumber of bytes this server is allowed to use for storage.
threads32uNumber of worker threads requested. (see doc/threads.txt)
conn_yields64uNumber of times any connection yielded to another due to hitting the -R limit.
hash_power_level32uCurrent size multiplier for hash table
hash_bytes64uBytes currently used by hash tables
hash_is_expandingboolIndicates if the hash table is being grown to a new size
expired_unfetched64uItems pulled from LRU that were never touched by get/incr/append/etc before expiring
evicted_unfetched64uItems evicted from LRU that were never touched by get/incr/append/etc.
slab_reassign_runningboolIf a slab page is being moved
slabs_moved64uTotal slab pages moved
crawler_reclaimed64uTotal items freed by LRU Crawler
lrutail_reflocked64uTimes LRU tail was found with active ref. Items moved to head to avoid OOM errors.

Source: https://github.com/memcached/memcached/blob/master/doc/protocol.txt

 

另,stackoverflow:

http://stackoverflow.com/questions/8896/can-i-get-memcached-running-on-a-windows-x64-64bit-environment

North Scale labs have released a build of memcached 1.4.4 for Windows x64:

http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available

http://labs.northscale.com/memcached-packages/

UPDATE: they have recently released Memcached Server - still FREE but enhanced distro with clustering, web-based admin/stats UI etc. (I'm not related to them in any way) Check it out at http://northscale.com/products/memcached.html and download at: http://www.northscale.com/download.php?a=d

UPDATE 2: NorthScale Memcached is no longer available as a standalone download. Now they have made it part of their commercial No-SQL DB offering called Membase. It can be configured to run in Memcached-only mode (i.e. without persistence) and there's a 100% free version too. Check it out here: http://www.membase.org/downloads

UPDATE 3: MemBase has slept with CouchDB and produced a hybrid product offering, called CouchBase. They still do offer a free "Community" version at http://www.couchbase.com/download

转载于:https://www.cnblogs.com/mrtiny/p/installing-memcached-windows.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/269868.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java高级面试题

Java多线程 1、线程池的原理&#xff0c;为什么要创建线程池&#xff1f; 答&#xff1a;1)线程池可以降低创建和销毁线程时的资源消耗&#xff0c;提高响应速度&#xff0c;提高现成的可管理性。 2)线程池构造参数&#xff1a; corePoolSize:核心线程数 maximumPoolSize:最大…

访问修改属性日志

1 import time as t2 3 class Record:4 def __init__(self,value None,name None):5 self.value value6 self.name name7 8 def __get__(self,instance,owner):9 with open(D://record.txt,a) as f: 10 f.write(%s变量于北京时…

不自定义异步方法的线程池默认使用SimpleAsyncTaskExecutor

如果不自定义异步方法的线程池默认使用SimpleAsyncTaskExecutor。SimpleAsyncTaskExecutor&#xff1a;不是真的线程池&#xff0c;这个类不重用线程&#xff0c;每次调用都会创建一个新的线程。并发大的时候会产生严重的性能问题。 定义通用线程池 EnableAsync Configuratio…

同步Android与PC的时间

同步Android与PC的时间 在做一些网络延迟测试的时候&#xff0c;需要同步Android设备或者模拟器与PC的时间&#xff08;要不然无法准确计算延迟&#xff09;&#xff0c;在这里记一下获取Android的时间戳以及MacOS的时间戳&#xff0c;均为纳秒级 Android: adb shell echo \$EP…

AopContext.currentProxy();为什么能获取到代理对象

在同一个类中&#xff0c;非事务方法A调用事务方法B&#xff0c;事务失效&#xff0c;得采用AopContext.currentProxy().xx()来进行调用&#xff0c;事务才能生效。 B方法被A调用&#xff0c;对B方法的切入失效&#xff0c;但加上AopContext.currentProxy()创建了代理类&#x…

java中 set,list,array(集合与数组)相互转换

1 public static Object[] List2Array(List<Object> oList) { 2 Object[] oArray oList.toArray(new Object[] {}); 3 // TODO 需要在用到的时候另外写方法&#xff0c;不支持泛型的Array. 4 return oArray; 5 } 6 7 publi…

@Async注解导致循环依赖,BeanCurrentlyInCreationException异常

使用Async异步注解导致该Bean在循环依赖时启动报BeanCurrentlyInCreationException异常的根本原因分析&#xff0c;以及提供解决方案 今天在自己项目中使用Async的时候&#xff0c;碰到了一个问题&#xff1a;Spring循环依赖&#xff08;circular reference&#xff09;问题。 …

人工智能:图像数字化相关的知识介绍

❤️作者主页&#xff1a;IT技术分享社区 ❤️作者简介&#xff1a;大家好,我是IT技术分享社区的博主&#xff0c;从事C#、Java开发九年&#xff0c;对数据库、C#、Java、前端、运维、电脑技巧等经验丰富。 ❤️个人荣誉&#xff1a; 数据库领域优质创作者&#x1f3c6;&#x…

《深入理解Java虚拟机》读书笔记

堆分配参数&#xff1a; -XX:PrintGC 使用该参数&#xff0c;虚拟机启动后&#xff0c;只要遇到GC就会打印日志&#xff1b; -XX&#xff1a;UseSerialGC 配置串行回收器&#xff1b; -XX&#xff1a;PrintGCDeltails 可以查看详细信息&#xff0c;包括各个区的情况 -Xms&#…

线程可见性和关键字volatile

线程可见性 可以看到程序变量running没volatile是死循环 加了volatile成功输出 public class VolitaleTest {private static volatile boolean running true;public static void main(String[] args) {Thread thread new Thread(() ->{long i 0L;while (running){i;}Sys…

codeforce 768B Code For 1

题意&#xff1a;将n分解为n/2, n%2, n/2三部分&#xff0c;再将n/2分解。。得到一个序列只有0和1&#xff0c;给出[l, r]问l到r有几个1#include <stdio.h> #define ll __int64 ll query(ll L,ll R,ll l,ll r,ll n){if(l r) return n;ll mid (lr)>>1, ans0;if(L …

每秒钟承载600万订单级别的无锁并行计算框架 Disruptor学习

1.来源 Disruptor是英国外汇交易公司LMAX开发的一个高性能队列&#xff0c;研发的初衷是解决内部的内存队列的延迟问题&#xff0c;而不是分布式队列。基于Disruptor开发的系统单线程能支撑每秒600万订单&#xff0c;2010年在QCon演讲后&#xff0c;获得了业界关注。 2.应用背…

logisim输出变成红色的e_新车实拍解析 福特Mustang Mach-E亮点实拍图解

福特Mustang Mach-E新车主要针对造型设计对外进行了首次亮相发布&#xff0c;对新车内饰以及具体新车方面的数据信息暂未公布。如果消费者想要了解这款新车&#xff0c;大家可以继续关注《杨总继续观察》带来这款新车的详细报道。新车在设计上可以看作是一款福特野马的电动跨界…

castle windsor学习----- Services and Components 两者的定义

转载于:https://www.cnblogs.com/lanpingwang/p/6534208.html

html5 接收蓝牙广播_蓝牙定位技术浅析(化工厂应用)

蓝牙定位基于RSSI(Received Signal Strength Indication&#xff0c;信号场强指示)定位原理。根据定位端的不同&#xff0c;蓝牙定位方式分为网络侧定位和终端侧定位。由于蓝牙由于是近场通信其定位精度取决于点位的部署密度&#xff0c;一般会设计成7-8米一个定位基站&#xf…

C#中的泛型和泛型集合

泛型 泛型引入了一个概念:类型参数。通过使用类型参数&#xff08;T&#xff09;减少了运行时强制转换或装箱操作的风险&#xff0c;通过泛型可以最大限度的重用代码&#xff0c;保护类型的安全及提高性能&#xff0c;他的最常见应用就是创建集合类&#xff0c;可以约束集合类中…

catia如何整列加工_”模具加工“最全面的诠释,你真的都懂了吗?

1定义模具加工(Mold Making)是指成型和制坯工具的加工&#xff0c;此外还包括剪切模和模切模具。通常情况下&#xff0c;模具有上模和下模两部分组成。将钢板放置在上下模之间&#xff0c;在压力机的作用下实现材料的成型&#xff0c;当压力机打开时&#xff0c;就会获得由模具…