初识Redis

1. 概述
redis官网定义:
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
Redis 是一个带持久化功能,比memcached更快的开源kv store!
这些,已经足够让人兴奋了。

2. 安装(当前2.4.4)

$ wget http://redis.googlecode.com/files/redis-2.4.4.tar.gz
$ tar xzf redis-2.4.4.tar.gz
$ cd redis-2.4.4
$ make
不用config,amazing!

3. 测试使用
启动redis-server
$ ./src/redis-server 

使用内置的redis-cli测试交互
$ ./src/redis-cli 
redis 127.0.0.1:6379> set name peter
OK
redis 127.0.0.1:6379> get name
"peter"

$ ./src/redis-cli -h 查看帮助


使用内置的benchmark测试性能:
$ ./src/redis-benchmark -n 50000 -q -r 10000 -d 20480
PING (inline): 8592.54 requests per second
PING: 19076.69 requests per second
MSET (10 keys): 1047.23 requests per second
SET: 7008.69 requests per second
GET: 6178.94 requests per second
INCR: 20000.00 requests per second

$ ./src/redis-benchmark -h 查看帮助

4. 持久化
redis提供持久化的功能选择,包括:
RDB:point-in-time snapshots of your dataset at specified intervals
AOF :persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset.
RDB模式定期将内存快照持久化到硬盘,aof则是通过写日志来实现持久化。

5. Virtual Memory
为了使redis使用超出内存限制,redis自己做了vm部分,遗憾的是:
Redis VM is now deprecated. Redis 2.4 will be the latest Redis version featuring Virtual Memory (but it also warns you that Virtual Memory usage is discouraged). We found that using VM has several disadvantages and problems. In the future of Redis we want to simply provide the best in-memory database (but persistent on disk as usually) ever, without considering at least for now the support for databases bigger than RAM. Our future efforts are focused into providing scripting, cluster, and better persistence.

6.Replication
redis提供主从同步功能以提高鲁棒性及可扩展性,特点如下;
1)使用简单,通过简单的配置即可使用
2)一主多从,从之间互相备份,对服务无阻塞
3)从库可以提供read-only queries

7. 支持客户端语言
c、c++、c#、java、php、Erlang、Go、Perl、Python.......
主流语言基本都支持

8.学习资料
官方主页:http://redis.io/
Google code:code.google.com/p/redis/    有一些关于缺陷的有趣的讨论

你可能感兴趣的:(初识Redis)