|
Redis是一个开源的,非常先进的键值存储系统,优点:快;支持多种结构: strings, hashes, lists, sets and sorted sets.
一、安装编译以及运行
1.下载安装并编译
$ curl -O http://redis.googlecode.com/files/redis-2.0.4.tar.gz
$ tar xzf redis-2.0.4.tar.gz
$ cd redis-2.0.4
$ make
2.运行服务
$ ./redis-server
3.然后进入客户端,使用之
$ ./redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
> set hello "world"
"OK"
> get hello
"world"
可以直接在其官方网站上直接运行各种命令进行测试,地址:http://try.redis-db.com/(ps:我在这个页面上尝试 append命令时,一直出错,本地安装的客户端没问题)
所有的命令都在这个页面 http://redis.io/commands
默认打开是 all
其实上方还有分类的,不是很明显,字体比较小;分别对应着各自的操作
Keys Strings Hashes Lists Sets Sorted Sets Pub/Sub Transactions Connection Server
二、使用ruby客户端
http://redis.io/clients这个页面上列出了redis的各种语言支持的客户端
推荐这个比较成熟稳定的版本,他在github的网页地址https://github.com/ezmobius/redis-rb
redis-rb
Repository Homepage
ezmobius soveran djanowski
very stable and mature client
安装此gem之后,便可以调用并使用之,比较简单
require "redis"
redis = Redis.new
>> redis.set "foo", "bar"
=> "OK"
>> redis.get "foo"
=> "bar" |
|
|