[Redis] Quick Start to Redis
Officially, Redis is not supported on Windows. There is, however, a 3.2.1 version of Redis that was ported to Windows by MSOpenTech.
Ruby:
1. install redis (gem install redis)
2. Run script:
Note that the host and port should match your server.
Here, I will show you how to get a redis instance running very quickly. If you want a more stable implementation, please read from https://redislabs.com/blog/redis-on-windows-8-1-and-previous-versions.
1. Download Redis
MSOpenTech has support for 3.2.1 of Redis.
Download the zip from https://github.com/MicrosoftArchive/redis/release
2. Running Redis Server + Cli
Unzip the downloaded zip, and run redis-server.exe
Then, run redis-cli.exe
In the cli, you should enter and expect:
127.0.0.1:6379> get foo
(nil)
127.0.0.1:6379> set foo 123
OK
127.0.0.1:6379> get foo
"123"
3. Accessing Redis Server from Python and Ruby Script
Python:
1. install redis (pip install redis)
2. Run script:
1. install redis (pip install redis)
2. Run script:
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
print("Setting bar to key, foo")
r.set('foo', 'bar')
print ("Getting value from key, foo")
print(r.get('foo'))
1. install redis (gem install redis)
2. Run script:
require "redis"
redis = Redis.new(host: "localhost", port: 6379, db: 0)
puts "Storing value into mykey"
redis.set("mykey", "hello world")
puts "I got my value back - #{redis.get("mykey")}"
Note that the host and port should match your server.
To double check, use the cli to run: get foo, and expect it to return 'bar' (modified by the python script)
Resources
https://redislabs.com/blog/redis-on-windows-8-1-and-previous-versions/
https://redislabs.com/ebook/appendix-a/a-3-installing-on-windows/a-3-3-installing-python-on-windows/
Comments
Post a Comment