Exposure at work to redis, Redis is a very efficient key-value database, widely used in the project, but it is obvious shortcomings redis for memory processing in the project at the beginning of the line, you must memory planning and reasonable, otherwise memory is prone to burst phenomenon, generally more reasonable amount of memory for the computer's physical memory 3/5.
redis provides a variety of data types, I often use a string, hash, list, set, sorted set, to meet the basic requirements of the project for the data type. We are using redis Java client, providing a series of commands for redis corresponding api. redis persistence provides a variety of strategies, but we do not have the persistence, under their own research, AOF is the most reliable way of feeling, principle and mysql binary log is very similar to the operation information is recorded written document, to read the log from the server and perform operations.
In the usual network development you may often need to adjust the data storage details, so if the previous data is still resident in memory, cause a lot of features not work properly, so after adjustment details, you need to redis database flushdb operation.
redis and ssdb very suitable for use in certain scenarios, such as some data can only remain in the database for 2 minutes, similar to the YY channel T person, after fixing a few minutes to come in, you can use the command setex key seconds value, then determine whether the expired You can exists key command.
redis commonly used commands website: http: //redis.readthedocs.org/en/latest/ covers redis command and demo.
Before take ssdb said redis, because ssdb very good compatibility of the redis api. Redis is a good substitute.
ssdb relative to redis there is a lot of advantages: redis 100 times the capacity of a database that can store the amount of billions of data. Redis relatively speaking, occupy very little memory. So he is to download the ssdb, the following are ssdb build process.
Environment: Ubuntu 14.04
Virtual machine A: 192.168.1.251
VM B: 192.168.1.252
My two virtual machines are respectively mounted on different physical machines, but are used in a bridging mode, ip ip addresses are in the same segment.
Online are installed under ssdb in two virtual machines, respectively.
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
sudo make install
These can be found in ssdb official website, http: //www.ideawu.com/ssdb/zh_cn/.
ssdb from the main building is actually very simple, you just need to find ssdb.conf in two virtual machines ssdb installation directory.
sudo vi ssdb.conf
ip modify server virtual machine under the default IP address.
Virtual Machine A:
port: 8888 // I did not change the port, use the default
Virtual machine B:
This is the basic configuration.
Now as long as the basis for the next ssdb.conf A Configuration:
# To identify a master even if it moved (ip, port changed)
# If set to empty or not defined, ip: port will be used.
# Sync | mirror, default is sync
Note: In the above configuration, do not use the spacebar to use tab.
You can now start the ssdb.
Then you can use the command line tools provided ssdb to operate.
Virtual machine A: ./ssdb-cli -h 192.168.1.251 -p 8888
VM B: ./ssdb-cli -h 192.168.1.252 -p 8888