The
Redis is a key-value storage system. Like memcached, it supports a relatively larger number of stored value types, including string (string), list (linked list), set (set), Zset (sorted set– ordered set), and hash (hash type). These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic. On this basis, Redis supports a variety of different ways of ordering. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to the disk or writes the modification operation to the appended record file, and on this basis, it realizes the Master-slave (master-slave) synchronization. The
Redis is a high-performance key-value database. The emergence of Redis, to a large extent, compensates for the shortage of such key/value storage in memcached, and in some cases can complement the relational database well. It provides Java,c/c++,c#,php,javascript,perl,object-c,python,ruby,erlang and other clients, easy to use. [1]
Redis supports master-slave synchronization. Data can be synchronized from the primary server to any number of servers, from which the server can be associated with other primary servers from the server. This enables Redis to perform a single layer tree replication. Saving can be intentionally or unintentionally to the data to write operations. With the full implementation of the publish/subscribe mechanism, you can subscribe to a channel and receive a full message publishing record from the primary server when you synchronize the tree anywhere from the database. Synchronization is useful for the scalability of read operations and for data redundancy.
Redis's official website address, very good to remember, is Redis.io. (specially checked, the domain name suffix io belongs to the national domain name, is British Indian Ocean territory, namely the British Indian Ocean Territory)
Currently, VMware is financing the development and maintenance of REDIS projects.
1.windows
Download the Windows version, unzip it, download the address redis server download
Enter the appropriate directory according to the operating system
Start the Redis service side Redis-server.exe redis.conf
Client Redis-cli.exe test can be used when the server is started successfully
Redis-cli.exe-h 127.0.0.1-p 6379
Set Czy 123
Get Czy
Look at the client just up
Here to open two command terminals, using Redis, the server is always open.
Redis configuration file Parameters
[HTML] View plain copy print? #是否以后台守护进程运行, the default is no, value Yes, no Daemonize no #pid文件存放路径 pidfile/var/run/redis.pid #配置redi s port, default 6379 port 6379 #绑定ip. The default binding all native IP, generally used in the server under multiple IP, you can only monitor intranet server IP, guarantee service security bind 127.0.0.1 #sock文件 unixsocket/tmp/redis.sock #客
User-side timeout, unit seconds Timeout #log级别, support four levels, debug,notice,verbose,warning loglevel verbose #log文件路径 logfile #log输出到标准设备, logs not write files, output to empty devices,/deb/null logfile stdout #保存快照的频 Rate, you can set multiple conditions for how often you save snapshots when you perform a certain number of writes during a long period of time. If all is commented out, the memory data is not persisted.
If you just use Redis only as cache, do not turn on the persistence feature save <seconds> <changes> save 900 1 #是否使用压缩 rdbcompression
#快照数据库名称 dbfilename #数据库存放路径 dir #redis主从 procedure to fill in the main IP and port number from the Lord do not have to do any setup Slaveof <masterip> <masterport> #主库服务器口令, this is not required if the primary server does not have Requirepass open Masterauth <master-password >
#在master服务器挂掉或者同步失败时, whether to continue providing services from the server Slave-serve-stale-data Yes #设置redis服务密码, if it is turned on, the client connection requires a specified password, or the operation will
Show no permissions Requirepass foobared #命令改名, equivalent to Linux alias, you can use the function to mask some dangerous commands Rename-command #最大连接数 0 means that the MaxClients 128 #最大使用内存 (allocated memory) is not restricted, and the production environment is recommended to adjust accordingly, we use only to do cache, limit 2G. By default, Redis consumes all available memory MaxMemory <bytes> #过期策略, offering six Strategies Maxmemory-policy VOLATILE-LRU Vol. ATILE-LRU//delete expired and LRU key (default) ALLKEYS-LRU//delete LRU algorithm key volatile-random//random deletion is about to expire key Allkeys->rando m///random Delete volatile-ttl//delete upcoming noeviction//Never period, return error #是否开启appendonlylog, open words each write operation will remember a log. Equivalent to the binlog of MySQL; each Redis startup reads this file to build the complete data. Even if you delete the Rdb file, the data is secure appendonly #日志文件的名称, the default appendonly.aof appendfilename appendonly.aof #异步写append file Policy 。 Similar to the MySQL things log write way.
Three kinds of appendfsync appendfsync always//sync, flush to disk for each write, safe and slow. Appendfsync EVerysec//sec Write (default value, recommended value) with MySQL Appendfsync no//to the operating system to do flush action #虚拟内存开关 vm-enabled No #swap文件, different Redis swap files cannot be shared. And in the production environment, it is not recommended to place the TMP directory Vm-swap-file/tmp/redis.swap #vm大小限制. 0: No limit, recommended 60-80% available memory size vm-max-memory 0 #根据缓存内容大小调整, default 32 bytes Vm-page-size #page数 。 Each 8 page consumes 1 bytes of memory. Vm-page-size * Vm-pages equals the swap file size vm-pages 134217728 #vm The maximum number of IO threads. Note: 0 flags prohibit the use of VM Vm-max-threads 4