memcached-redis
http://www.runoob.com/memcached/memcached-cas.html
https://github.com/memcached/memcached/blob/master/doc/protocol.txt 很重要,解释了所有相关含义
==============================
[root@cn-21 ~]# ps -ef|grep mem
systemd+ 3338 3319 0 2017 ? 01:13:09 memcached
root 29927 29897 0 15:34 pts/1 00:00:00 grep --color=auto mem
[root@cn-21 ~]# rpm -qa|grep mem
memcached-1.4.15-10.el7_3.1.x86_64
[root@cn-21 ~]# rpm -ql memcached
/etc/sysconfig/memcached
/usr/bin/memcached
/usr/bin/memcached-tool
/usr/lib/systemd/system/memcached.service
/usr/share/doc/memcached-1.4.15
/usr/share/doc/memcached-1.4.15/AUTHORS
/usr/share/doc/memcached-1.4.15/CONTRIBUTORS
/usr/share/doc/memcached-1.4.15/COPYING
/usr/share/doc/memcached-1.4.15/ChangeLog
/usr/share/doc/memcached-1.4.15/NEWS
/usr/share/doc/memcached-1.4.15/README.md
/usr/share/doc/memcached-1.4.15/protocol.txt
/usr/share/doc/memcached-1.4.15/readme.txt
/usr/share/doc/memcached-1.4.15/threads.txt
/usr/share/man/man1/memcached-tool.1.gz
/usr/share/man/man1/memcached.1.gz
[root@cn-21 ~]# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
==============================
Memcached本身是使用C开发的,客户端可以是php、C#、或者java。
==============================
命令汇总
stats items
stats sizes
set runoob 0 900 9
get runoob
flush_all
===============================
[root@cn-21 ~]# telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
stats items
END
stats slabs
STAT 7:chunk_size 384
STAT 7:chunks_per_page 2730
STAT 7:total_pages 1
STAT 7:total_chunks 2730
STAT 7:used_chunks 0
STAT 7:free_chunks 2730
STAT 7:free_chunks_end 0
STAT 7:mem_requested 0
STAT 7:get_hits 72
STAT 7:cmd_set 49
STAT 7:delete_hits 18
STAT 7:incr_hits 0
STAT 7:decr_hits 0
STAT 7:cas_hits 0
STAT 7:cas_badval 0
STAT 7:touch_hits 0
STAT 9:chunk_size 600
STAT 9:chunks_per_page 1747
STAT 9:total_pages 1
STAT 9:total_chunks 1747
STAT 9:used_chunks 0
STAT 9:free_chunks 1747
STAT 9:free_chunks_end 0
STAT 9:mem_requested 0
STAT 9:get_hits 4
STAT 9:cmd_set 2
STAT 9:delete_hits 0
STAT 9:incr_hits 0
STAT 9:decr_hits 0
STAT 9:cas_hits 0
STAT 9:cas_badval 0
STAT 9:touch_hits 0
STAT 10:chunk_size 752
STAT 10:chunks_per_page 1394
STAT 10:total_pages 1
STAT 10:total_chunks 1394
STAT 10:used_chunks 0
STAT 10:free_chunks 1394
STAT 10:free_chunks_end 0
STAT 10:mem_requested 0
STAT 10:get_hits 82
STAT 10:cmd_set 44
STAT 10:delete_hits 0
STAT 10:incr_hits 0
STAT 10:decr_hits 0
STAT 10:cas_hits 0
STAT 10:cas_badval 0
STAT 10:touch_hits 0
STAT 11:chunk_size 944
STAT 11:chunks_per_page 1110
STAT 11:total_pages 1
STAT 11:total_chunks 1110
STAT 11:used_chunks 0
STAT 11:free_chunks 1110
STAT 11:free_chunks_end 0
STAT 11:mem_requested 0
STAT 11:get_hits 8
STAT 11:cmd_set 2
STAT 11:delete_hits 0
STAT 11:incr_hits 0
STAT 11:decr_hits 0
STAT 11:cas_hits 0
STAT 11:cas_badval 0
STAT 11:touch_hits 0
STAT active_slabs 4
STAT total_malloced 4194304
END
=====================
stats settings
STAT maxbytes 67108864
STAT maxconns 1024
STAT tcpport 11211
STAT udpport 11211
STAT inter NULL
STAT verbosity 0
STAT oldest 0
STAT evictions on
STAT domain_socket NULL
STAT umask 700
STAT growth_factor 1.25
STAT chunk_size 48
STAT num_threads 4
STAT num_threads_per_udp 4
STAT stat_key_prefix :
STAT detail_enabled no
STAT reqs_per_event 20
STAT cas_enabled yes
STAT tcp_backlog 1024
STAT binding_protocol auto-negotiate
STAT auth_enabled_sasl no
STAT item_size_max 1048576
END
=====================
stats sizes
STAT sizes_status disabled
set runoob 0 900 9
memcached
STORED
get runoob
VALUE runoob 0 9
memcached
END
flush_all
OK
get runoob
END
======================
<command name> <key> <flags> <exptime> <bytes> [noreply]\r\n
cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n
按秒算,5是数据库的长度,即5字节,多于5和小于5都会报错
set file 0 300 5
iiiiii
CLIENT_ERROR bad data chunk
ERROR
set file 0 300 5
iiii
CLIENT_ERROR bad data chunk
ERROR
set file 0 300 5
iiiii
STORED
======================
[root@cn-21 ~]# memcached-tool localhost:11211 stats
#localhost:11211 Field Value
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 0
bytes_read 139360283
bytes_written 232272906
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 147
cmd_get 298
cmd_set 99
cmd_touch 0
conn_yields 0
connection_structures 52
crawler_items_checked 1
crawler_reclaimed 0
curr_connections 38
curr_items 0
decr_hits 0
decr_misses 0
delete_hits 18
delete_misses 0
direct_reclaims 0
evicted_active 0
evicted_unfetched 0
evictions 0
expired_unfetched 34
get_expired 0
get_flushed 0
get_hits 168
get_misses 130
hash_bytes 524288
hash_is_expanding 0
hash_power_level 16
incr_hits 0
incr_misses 0
libevent 2.0.21-stable
limit_maxbytes 67108864
listen_disabled_num 0
log_watcher_sent 0
log_watcher_skipped 0
log_worker_dropped 0
log_worker_written 0
lru_bumps_dropped 0
lru_crawler_running 0
lru_crawler_starts 203490
lru_maintainer_juggles 12327347
lrutail_reflocked 22
malloc_fails 0
max_connections 1024
moves_to_cold 112
moves_to_warm 27
moves_within_lru 0
pid 1
pointer_size 64
reclaimed 41
rejected_connections 0
reserved_fds 20
rusage_system 3602.709727
rusage_user 795.646915
slab_global_page_pool 0
slab_reassign_busy_deletes 0
slab_reassign_busy_items 0
slab_reassign_chunk_rescues 0
slab_reassign_evictions_nomem 0
slab_reassign_inline_reclaim 0
slab_reassign_rescues 0
slab_reassign_running 0
slabs_moved 0
threads 4
time 1515488925
time_in_listen_disabled_us 0
total_connections 177
total_items 98
touch_hits 0
touch_misses 0
uptime 2770390
version 1.5.3
=============================================
redis
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
cd redis-4.0.6
make
cd src/
./redis-server
./redis-cli
先启动server,再用cli去连接,开两个终端窗口
==============================
[root@localhost src]# ./redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
[root@localhost src]# ./redis-cli
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> CONFIG GET *
127.0.0.1:6379> client list
id=3 addr=127.0.0.1:15897 fd=8 name= age=617 idle=520 flags=N db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=subscribe
id=4 addr=127.0.0.1:15921 fd=9 name= age=584 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
[root@localhost src]# ./redis-benchmark -n 10000
配置这个之后,远程才可以连接
127.0.0.1:6379> CONFIG SET protected-mode no
OK
127.0.0.1:6379> set aa bb
OK
=====================
package java20180118;
import redis.clients.jedis.Jedis;
public class Redis {
public static void main(String[] args) {
//连接本地的 Redis 服务
Jedis jedis = new Jedis("192.168.3.225");
System.out.println("连接成功");
//查看服务是否运行
System.out.println("服务正在运行: "+jedis.get("aa"));
}
}
=======================
memcached-redis的更多相关文章
- Python自动化 【第十一篇】:Python进阶-RabbitMQ队列/Memcached/Redis
本节内容: RabbitMQ队列 Memcached Redis 1. RabbitMQ 安装 http://www.rabbitmq.com/install-standalone-mac.htm ...
- python对缓存(memcached,redis)的操作
1.Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的 ...
- centos7下搭建nginx+php7.1+mariadb+memcached+redis
一.环境准备 1.首先介绍一下环境,以及我们今天的主角们 我用的环境是最小化安装的centos7,mariadb(江湖传言mysql被oracle收购后,人们担心像java一样毁在oracle手上于是 ...
- Memcached & Redis使用
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度.Memcached ...
- Memcached, Redis, MongoDB区别
mongodb和memcached不是一个范畴内的东西.mongodb是文档型的非关系型数据库,其优势在于查询功能比较强大,能存储海量数据.mongodb和memcached不存在谁替换谁的问题. 和 ...
- 17.Python笔记之memcached&redis
作者:刘耀 博客:www.liuyao.me 博客园:www.cnblogs.com/liu-yao 一.Memcached 1.介绍 Memcached 是一个高性能的分布式内存对象缓存系统,用于动 ...
- memcached/redis安全性
最近看到说redis,memcached服务器安全的问题,想想也是,使用这两种服务N年了,由于历史问题吧,工作中基本是以memcached为主,后来才慢慢引入运用redis.由于memcached是没 ...
- Memcached·Redis缓存的基本操作
Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度 ...
- NOSQL学习之一:Memcached, Redis, MongoDB区别
Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代理. Memcached是一个自由开源的,高性能,分布式内存对象缓存系统. MongoDB是一个基于分布 ...
- 缓存:Memcached Redis
一.Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的 ...
随机推荐
- excel加密文件破解代码
1. AIT+F11 2. 代码 3. F5 Public Sub AllInternalPasswords()' Breaks worksheet and workbook structure ...
- while循环和递归
这个问题是在数据结构的二叉树添加结点的时候碰见 添加新结点的时候可以用while循环自身解决(这里这个方式更好) 也可以用递归解决 递归就像小明去楼顶取东西 ,从一楼开始爬,看,不是的,继续爬,每层 ...
- dom常用操作
创建节点:document.createElement(元素名), document.createTextNode(文本内容) 添加节点:parent.appendChild(newChild) 移除 ...
- 从多个角度来理解协方差(covariance)
起源:协方差自然是由方差衍生而来的,方差反应的是一个变量(一维)的离散程度,到二维了,我们可以对每个维度求其离散程度,但我们还想知道更多.我们想知道两个维度(变量)之间的关系,直观的举例就是身高和体重 ...
- 『TensorFlow』读书笔记_进阶卷积神经网络_分类cifar10_下
数据读取部分实现 文中采用了tensorflow的从文件直接读取数据的方式,逻辑流程如下, 实现如下, # Author : Hellcat # Time : 2017/12/9 import os ...
- ABBYY Cup 3.0G3. Good Substrings
题意:定义一个串合法,在n个串中出现次数在li到ri中.问s的所有本质的子串有是多少合法的 题解:把所有串用分隔符分开建sam,记录一个该节点对应每个串的出现次数,topo排序后,当该节点s出现次数不 ...
- 一个二维码如何自动识别是安卓(Android)还是苹果(IOS)
思考问题: 通常,我们开发一个APP,有Android版本.IOS版本. 但是只有一个二维码?怎么办呢? 怎么让IOS用户扫描二维码下载IOS版本,Android用户扫描二维码下载到Android版本 ...
- 在500jsp错误页面获取错误信息
自定义异常发生时的错误处理页面: 1) 只要定义page指示元素的errorPage属性就可以指定当前页面发生异常时应该交给哪个页面进行处理,例如:<%@page errorPage=" ...
- PythonWEB框架之Tornado
前言 Tornado(龙卷风)和Django一样是Python中比较主流的web框架,Tornado 和现在的主流 Web 服务器框架也有着明显的区别:Tornado自带socket,并且实现了异步非 ...
- 使用js实现思维导图
使用js实现思维导图 demo:http://rockyren.github.io/mindmaptree/ 源码:http://github.com/RockyRen/mindmaptree/tre ...