美文网首页
memcache学习笔记

memcache学习笔记

作者: 追梦人在路上不断追寻 | 来源:发表于2020-07-27 23:45 被阅读0次

memcache 和memcached的关系

memcache是客户端,memcached是服务器端,memcached一般以守护进程运行。

memcached安装

  • 下载libevent源码,编译安装libevent
tar zxvf libevent.tar.gz
cd libevent-1.2
./configure --prefix=/usr
make
make install
  • 下载memcached源码,编译安装memcached
cd /tmp
tar zxvf memcached.tar.gz
cd memcached
./configure --with-libevent=/usr
make
make install

memcahce类方法

Memcache {
 bool add ( string $key , mixed $var [, int $flag [, int $expire ]] )
bool addServer ( string $host [, int $port = 11211 [, bool $persistent [, in
t $weight [, int $timeout [, int $retry_interval [, bool $status [, callback
$failure_callback [, int $timeoutms ]]]]]]]] )
 bool close ( void )
bool connect ( string $host [, int $port [, int $timeout ]] )
 int decrement ( string $key [, int $value = 1 ] )
bool delete ( string $key [, int $timeout = 0 ] )
bool flush ( void )
string get ( string $key [, int &$flags ] )
array getExtendedStats ([ string $type [, int $slabid [, int $limit = 100 ]]]
)
 int getServerStatus ( string $host [, int $port = 11211 ] )
array getStats ([ string $type [, int $slabid [, int $limit = 100 ]]] )
string getVersion ( void )
int increment ( string $key [, int $value = 1 ] )
mixed pconnect ( string $host [, int $port [, int $timeout ]] )
 bool replace ( string $key , mixed $var [, int $flag [, int $expire ]] )
 bool set ( string $key , mixed $var [, int $flag [, int $expire ]] )
bool setCompressThreshold ( int $threshold [, float $min_savings ] )
 bool setServerParams ( string $host [, int $port = 11211 [, int $timeout [,
int $retry_interval = false [, bool $status [, callback $failure_callback ]]]]
] )
}

memcache配置

memcache.allow_failover boolean
是否在发生错误时(对用户)透明的转移到其他服务器

memcache.max_failover_attempts integer
定义在写入和获取数据时最多尝试的服务器次数(即:故障转移最大尝试数),仅和memcache.allow_failover 结合使用。

memcache.chunk_size integer
数据传输块大小,这个值越小网络 I/O 次数越多,如果发现莫名的速度降低, 可以尝试将此值调至
32768。

memcache.default_port string
在尝试连接 memcache 的时候如果没有单独指定端口默认使用的 TCP 端口号。

memcache.hash_strategy string
控制 key 到服务器的映射(分布式)策略。

memcache.hash_function string
控制在 key-server 映射时使用哪个 hash 函数 crc32 标明使用标准 CRC32 进行 hash,fnv 则说明
使用 FNV-1a。

session.save_handler string
当值为 memcache 时标记使用 memcache 作为 session 处理器。

session.save_path string
定义一个逗号分割的用于 session 存储的服务器 url 列表,例如: "tcp://host1:11211,
tcp://host2:11211".

每个 url 可以包含参数,这些参数于方法 Memcache::addServer()的参数相同。比如:
"tcp://host1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

相关文章

  • memcache学习笔记

    memcache简介 memcache是一个自由、源码开放、高性能、分布式的分布式内存对象缓存系统,用于动态WEB...

  • memcache学习笔记

    memcache 和memcached的关系 memcache是客户端,memcached是服务器端,memcac...

  • linux 下的Memcached安装和配置

    原来学习memcache做的一点笔记!! 服务器端主要是安装memcache服务器端,目前的最新版本是 memca...

  • cache书目录

    memcache memcache是什么 memcache的工作原理 memcache的特点 memcache如何...

  • Memcache 基础笔记

    (一):基础概念 memcache是什么? Memcache 是一个高性能的分布式内存对象缓存系统,用于动态Web...

  • PHP如何安装memcache扩展

    安装memcache只是安装memcache的客户端,要让PHP与memcache连接还得在PHP中安装memca...

  • laravel操作memcache笔记!

    更改cache.php中cache_driver值为memcached。 时间单位为分钟

  • MemCache详细讲解

    1 MemCache讲解 1.1 MemCache是什么 MemCache是一个自由、源码开放、高性能、分布式的分...

  • MemCache 入门极简教程

    MemCache 概述 MemCache虽然被称为”分布式缓存”,但是MemCache本身完全不具备分布式的功能 ...

  • linux使用docker安装memcache

    拉取memcache镜像,(memcache:latest)指最新版本,也可指定版本号拉取(memcache:1....

网友评论

      本文标题:memcache学习笔记

      本文链接:https://www.haomeiwen.com/subject/ubcxrktx.html