沃梦达 / IT编程 / 数据库 / 正文

redis分布式应用

1、安装wget http://download.redis.io/releases/redis-3.0.7.tar.gztar xvf redis-3.0.7.tar.gzcd redis-3.0.7makesudo make install PREFIX=/usr/local/redissudo mkdir -p /usr/local/redis/etcsudo cp redis.co...

1、安装

wget http://download.redis.io/releases/redis-3.0.7.tar.gz
tar xvf redis-3.0.7.tar.gz
cd redis-3.0.7
make
sudo make install PREFIX=/usr/local/redis
sudo mkdir -p /usr/local/redis/etc
sudo cp redis.conf /usr/local/redis/etc
cd src
sudo cp mkreleasehdr.sh /usr/local/red

 

2、python client

sudo apt-get install python-pip
sudo pip install virtualenv
virtualenv -p /usr/bin/python env
source env/bin/activate
pip install redis

import redis
client = redis.StrictRedis(host='127.0.0.1', port=6379)
key = "hello"
client.set(key, "python-redis")
value = client.get(key)
print "key:" + key + ", value:" + value 

 

3、nodejs client

npm install redis --save

const redis = require('redis')
const client = redis.createClient(6379, 'localhost')
client.set('hello', 'node-redis')
client.get('hello', function(err, value){ console.log(value) })

 

本文标题为:redis分布式应用