[转]memCached 客户端
memcache客户端下载 http://code.google.com/p/memcached/wiki/Clients ----------------------------------------------------------------------------------------------------------------------------------- memcached是什么? 许多Web应用都将数据保
memcache客户端下载
http://code.google.com/p/memcached/wiki/Clients
-----------------------------------------------------------------------------------------------------------------------------------
memcached是什么?
许多Web应用都将数据保存到DBMS中,应用服务器从中读取数据并在浏览器中显示。 但随着数据量的增大、访问的集中,就会出现RDBMS的负担加重、数据库响应恶化、 网站显示延迟等重大影响。
memcached 是以LiveJournal 旗下Danga Interactive 公司的Brad Fitzpatric 为首开发的一款软件。memcached是高性能的分布式内存缓存服务器,也就是可以允许不同主机上的多个用户同时访问这个缓存系统,这种方法不仅解决了共享内存只能是单机的弊端,同时也解决了数据库检索的压力,最大的优点是提高了访问获取数据的速度。 一般的使用目的是,通过缓存数据库查询结果,减少数据库访问次数,以提高动态Web应用的速度、 提高可扩展性。一般情况下memcached的用途如下:
Memcached的内置内存存储方式
为了提高性能,memcached中保存的数据都存储在memcached内置的内存存储空间中。由于数据仅存在于内存中,因此重启memcached、重启操作系统会导致全部数据消失。另外,内容容量达到指定值之后,就基于LRU(Least?Recently?Used)算法自动删除不使用的缓存。memcached本身是为缓存而设计的服务器,因此并没有过多考虑数据的永久性问题。所以我们在取值时,应考虑缓存中的数据已经被替换掉或者是程序员自已对数据置了过期时间的情况。即应判断 get(key)==null的情况。
Memcached的架构:
memcached尽管是“分布式”缓存服务器,但服务器端并没有分布式功能。各个memcached不会互相通信以共享信息。那么,怎样进行分布式完全取决于客户端的实现。
memcached的分布式:
我们采用的memcached for java client所使用的分布式算法是Consistent?Hashing算法。
windows下memCached服务器端搭建:
1.?????? 下载 memcache(http://jehiah.cz/projects/memcached-win32/)的windows稳定版,解压到某一路径,即为memcached_home。
2.?????? 在终端(也即cmd命令界面)下输入 ‘%memcached_home%"memcached.exe -d install’ 安装
3.?????? 再输入: ‘%memcached_home%"memcached.exe -d start’ 启动。注意: 以后memcached将作为windows的一个服务每次开机时自动启动,这样服务器端已经安装完毕了。
4.?????? Memcached常用参数说明:
memcached -d –m 1024? -l 192.200.1.75 -p 11211
-d 以守护程序(daemon)方式运行 memcached;
-m 设置 memcached可以使用的内存大小,单位为 M;
-l 设置监听的 IP 地址,如果是本机的话,通常可以不设置此参数;
-p 设置监听的端口,默认为 11211,所以也可以不设置此参数;
Linux下的安装:
memcached安装与一般应用程序相同,configure、make、make?install就行了。
$?wget?http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
$?tar?zxf?memcached-1.2.5.tar.gz
$?cd?memcached-1.2.5
$?./configure
$?make
$?sudo?make?install
默认情况下memcached安装到/usr/local/bin下。
从终端输入:$?/usr/local/bin/memcached?-p?11211?-m?64m?-vv即可启动memcached
Memcached的java客户端的使用。
1.?????? 下载Memcached 的java客户端包( http://www.whalin.com/memcached/#download)
2.?????? 根据不同版本构建到工程中。
3.?????? 由于Memcached的客户端在处理大对象的序列化时,效率较差,通过hessian的序列化工具进行了相应模块的替换。优化后的memcached java client 加入到项目构建路径中即可。
4.?????? 调用方法详见API。
5.?????? 依赖的包及生成后的memcached的包:
-----------------------------------------------------------------------------------------------------------------------------------
Memcached?是danga.com(运营LiveJournal的技术团队)开发的一套分布式内存对象缓存系统,用于在动态系统中减少数据库负载,提升性能。
??? 网上有很多讲到Memcached For Linux的安装教程,但是Memcached For Win32 and Python的就甚少,偶尔google找到一篇
比较相近的英文教程,觉得很不错就打算翻译下来,并且写一个Hello World的memcached实例。
安装部分来自 原文?
1.下载 memcached 1.2.1 for Win32?.
?
2.把memcached-1.2.1-win32.zip解包到你想要的路径下?(如:C:/memcached-1.2.1-win32)
?
3.打开命令行(在开始菜单中的"运行",输入"cmd"),使用以下的命令安装:?
?
- C:/memcached-1.2.1-win32/memcached.exe?-d?install??
安装完成之后,再执行以下命令来启动memcached:
- C:/memcached-1.2.1-win32/memcached.exe?-d?start????
这样memcached会使用默认的端口(11211)来启动,启动成功的话,你可以在任务管理器中看到memcached.exe
?
?
4.为了和memcached通信,你需要安装一个memcached客户端?,来对memcached做“增删改”操作。memcached有很多个客户
端程序可以使用,对应于各种语言,有各种语言的客户端。基于C语言的有libmemcache、 APR_Memcache;基于Perl的有Cache::Memcached;另外还有Php、Python、Ruby、Java、C#等语言的支持。其中PHP的客户端是最多的,你可以在网上搜
索到大部分,这里我只介绍python的客户端。
5.获取最新版的memcached python客户端: python-memcached-latest.tar.gz?
6.把python-memcached-latest.tar.gz解压到任意路径?(如c:/python-memcached-1.45)
7.在命令行中cd到c:/python-memcached-1.45目录下:?
?
- cd?c:/python-memcached-1.45??
?
8.然后运行以下命令安装python-memcached:?
- python?setup.py?build??
- python?setup.py?install??
这样python-memcached就成功安装到python库中。如果提示ImportError: No module named setuptools?,请先安装
setuptools for win32?。
9.运行以下代码来测试python-memcached是否成功安装?
[python]? view plain copy
- import?memcache??
- #创建连接??
- mc_client?=?memcache.Client(['127.0.0.1:11211'],?debug=0)??
- #写、读??
- mc_client.set("key_a",?"value_a")??
- value?=?mc_client.get("key_a")??
- print?"key_a?'s?value?in?memcached?is:?%s"?%(value)??
- #删??
- mc_client.delete("key_a")??
- value?=?mc_client.get("key_a")??
- print?"key_a?'s?value?in?memcached?after?deleted?is:?%s"?%(value)??
- #自增、自减??
- mc_client.set("count_key",?"11")??
- value?=?mc_client.get("count_key")??
- print?"general?value:?",?value??
- mc_client.incr("count_key")??
- value?=?mc_client.get("count_key")??
- print?"general?value?after?increment:?",?value??
- mc_client.decr("count_key")??
- value?=?mc_client.get("count_key")??
- print?"general?value?after?decrement:?",?value??
成功的话会显示以下内容:
?
- key_a?'s?value?in?memcached?is:?value_a??
- key_a?'s?value?in?memcached?after?deleted?is:?None??
- general?value:??11??
- general?value?after?increment:??12??
- general?value?after?decrement:??11??
至此,Memcached For Win32 和 Memcached Python Client安装完成。
-------------------------------------------------------------------------------------------------------------
Memcached是被广泛使用的分布式缓存技术。不同的语言有不同的Memcached客户端程序,对于Java客户端来说,首推Memcached Java Client(http://github.com/gwhalin/Memcached-Java-Client )。
这次,Memcached Java Client推出的2.6.1发布版是基于全新的performance分支,具有如下重大改进:
- 较之老版本,在性能上有300%左右的提升;
- 兼容老版本,用户无须修改自己的源代码;
- 支持多个memcached协议,包括text,udp和binary协议;
- 支持SASL认证机制;
- 重新实现的连接池,修复了之前的连接数太多所导致的OutOfMemory异常;
- 加入了slf4j logger支持,使得开发人员可以方便的记录日志;
- 支持自定义的对象序列化方法。
这个分支由Schooner Information Technology贡献,并由Schooner中国团队完成开发,开发者是:
王新根,new.root@gmail.com;
李蒙,jowett.lee@gmail.com。
可以从这里下载二进制包:https://github.com/gwhalin/Memcached-Java-Client/downloads
源代码在github上,http://github.com/gwhalin/Memcached-Java-Client ,然后选择performance分支。
下面是一些性能测试的数据,包括了当前流行的Memcached Java Client。
其中,schooner指的是这个分支的text protocol, schooner_bin指的是binary protocol。
?
?
?
?
作者:zeo112140 发表于2013-6-8 11:41:06 原文链接
阅读:13 评论:0 查看评论
原文地址:[转]memCached 客户端, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Magnet link is a link method for downloading resources, which is more convenient and efficient than traditional download methods. Magnet links allow you to download resources in a peer-to-peer manner without relying on an intermediary server. This article will introduce how to use magnet links and what to pay attention to. 1. What is a magnet link? A magnet link is a download method based on the P2P (Peer-to-Peer) protocol. Through magnet links, users can directly connect to the publisher of the resource to complete resource sharing and downloading. Compared with traditional downloading methods, magnetic

Hongguo Short Play is not only a platform for watching short plays, but also a treasure trove of rich content, including novels and other exciting content. This is undoubtedly a huge surprise for many users who love reading. However, many users still don’t know how to download and watch these novels in Hongguo Short Play. In the following, the editor of this website will provide you with detailed downloading steps. I hope it can help everyone in need. Partners. How to download and watch the Hongguo short play? The answer: [Hongguo short play] - [Audio book] - [Article] - [Download]. Specific steps: 1. First open the Hongguo Short Drama software, enter the homepage and click the [Listen to Books] button at the top of the page; 2. Then on the novel page we can see a lot of article content, here

When you log in to someone else's steam account on your computer, and that other person's account happens to have wallpaper software, steam will automatically download the wallpapers subscribed to the other person's account after switching back to your own account. Users can solve this problem by turning off steam cloud synchronization. What to do if wallpaperengine downloads other people's wallpapers after logging into another account 1. Log in to your own steam account, find cloud synchronization in settings, and turn off steam cloud synchronization. 2. Log in to someone else's Steam account you logged in before, open the Wallpaper Creative Workshop, find the subscription content, and then cancel all subscriptions. (In case you cannot find the wallpaper in the future, you can collect it first and then cancel the subscription) 3. Switch back to your own steam
![VMware Horizon Client cannot be opened [Fix]](https://img.php.cn/upload/article/000/887/227/170835607042441.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
VMware Horizon Client helps you access virtual desktops conveniently. However, sometimes the virtual desktop infrastructure may experience startup issues. This article discusses the solutions you can take when the VMware Horizon client fails to start successfully. Why won't my VMware Horizon client open? When configuring VDI, if the VMWareHorizon client is not open, an error may occur. Please confirm that your IT administrator has provided the correct URL and credentials. If everything is fine, follow the solutions mentioned in this guide to resolve the issue. Fix VMWareHorizon Client Not Opening If VMW is not opening on your Windows computer

Recently, many users have been asking the editor, how to download links starting with 115://? If you want to download links starting with 115://, you need to use the 115 browser. After you download the 115 browser, let's take a look at the download tutorial compiled by the editor below. Introduction to how to download links starting with 115:// 1. Log in to 115.com, download and install the 115 browser. 2. Enter: chrome://extensions/ in the 115 browser address bar, enter the extension center, search for Tampermonkey, and install the corresponding plug-in. 3. Enter in the address bar of 115 browser: Grease Monkey Script: https://greasyfork.org/en/
![VMware Horizon client freezes or stalls while connecting [Fix]](https://img.php.cn/upload/article/000/887/227/170942987315391.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
When connecting to a VDI using the VMWareHorizon client, we may encounter situations where the application freezes during authentication or the connection blocks. This article will explore this issue and provide ways to resolve this situation. When the VMWareHorizon client experiences freezing or connection issues, there are a few things you can do to resolve the issue. Fix VMWareHorizon client freezes or gets stuck while connecting If VMWareHorizon client freezes or fails to connect on Windows 11/10, do the below mentioned solutions: Check network connection Restart Horizon client Check Horizon server status Clear client cache Fix Ho

123 cloud disk can download many files, so how to download files specifically? Users can select the file they want to download and click to download, or right-click the file and select download. This introduction to the method of downloading files from 123 cloud disk can tell you how to download it specifically. Friends who don’t know much about it should hurry up and take a look! How to download files from 123 cloud disk 1. First open the software, click on the software that needs to be downloaded, and then there will be a download button on it. 2. Or right-click the software and you can see the download button in the list. 3. There will be a download window, select the location to download. 4. After selecting, click Download to download these files.

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download
