[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.

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. 

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:
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'))
Ruby:
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

Popular posts from this blog

[Redis] Redis Cluster vs Redis Sentinel

[Unit Testing] Test Doubles (Stubs, Mocks....etc)

[Node.js] Pending HTTP requests lead to unresponsive nodeJS