惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

memcached

理解 memcached 源码 - Slab I - V2EX memcached 确实缺少一些高级特性 - V2EX memcached 有没有什么比较好用的命令行工具? - V2EX
学习 memcached 的一些记录 - V2EX
handsomeFu · 2017-03-05 · via memcached

什么是 memcached :

  1. memcached之前是danga的一个项目,最早是为 LiveJournal 服务的,当初设计师为了加速 LiveJournal 访问速度而开发的,后来被很多大型项目采用。官网是www.danga.com或者是memcached.org
  2. Memcached是一个高性能的分布式内存对象缓存系统,全世界有不少公司采用这个缓存项目来构建大负载的网站,来分担数据库的压力。 Memcached是通过在内存里维护一个统一的巨大的 hash 表,memcached能存储各种各样的数据,包括图像、视频、文件、以及数据库检索的结果等。简单的说就是将数据调用到内存中,然后从内存中读取,从而大大提高读取速度。

特征 :

memcached 作为高速运行的分布式缓存服务器,具有以下的特点。

  • 协议简单
  • 基于 libevent 的事件处理
  • 内置内存存储方式
  • memcached 不互相通信的分布式

支持的语言:

许多语言都实现了连接memcached的客户端,其中以 Perl 、 PHP 为主。仅仅memcached网站上列出的有:

  • Perl
  • PHP
  • Python
  • Ruby
  • C#
  • C/C++
  • Lua
  • 等等

Memcached 用户:

  • LiveJournal
  • Wikipedia
  • Flickr
  • Bebo
  • Twitter
  • Typepad
  • Yellowbot
  • Youtube
  • WordPress.com
  • Craigslist
  • Mixi

安装和启动memcached

  1. windows :

    • 安装:memcached.exe -d install
    • 启动:memcached.exe -d start
  2. linux ( Ubuntu/Debian ):

    • 安装:sudo apt-get install memcached
    • 启动:sudo service memcached start
  3. linux ( Redhat/Fedora/Centos ):

    • 安装:yum install memcached
    • 启动:yum service memcached start
  4. 可能出现的问题:

    • 提示你没有权限:在打开 cmd 的时候,右键使用管理员身份运行。
    • 提示缺少pthreadGC2.dll文件:将pthreadGC2.dll文件拷贝到windows/System32.
    • 不要放在含有中文的路径下面。
  5. 启动memcached

    • -d:这个参数是让memcached在后台运行。
    • -m:指定占用多少内存。
    • -p:指定占用的端口。默认端口是11211
    • -l:哪些 ip 地址可以链接。

telnet操作memcached

  1. 添加数据:
    • set
      • 语法:

        set key flas(0) timeout value_length
        value
        
      • 示例:

        set username 0 60 7
        xiaotuo
        
    • add
      • 语法:

        add key flas(0) timeout value_length
        value
        
      • 示例:

        add username 0 60 7
        xiaotuo
        

setadd的区别:add是只负责添加数据,不会去修改数据。如果添加的数据的key已经存在了,则添加失败,如果添加的key不存在,则添加成功。而set不同,如果memcached中不存在相同的key,则进行添加,如果存在,则替换。

  1. 获取数据:

    • 语法:
      get key
      
    • 示例:
      get username
      
  2. 删除数据:

    • 语法:
      delete key
      
    • 示例:
      delete username
      
    • flush_all:删除memcached中的所有数据。
  3. 查看memcached的当前状态:

    • 语法:stats