forked from robertzx/simple_worker_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis_worker.rb
37 lines (26 loc) · 955 Bytes
/
redis_worker.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require "simple_worker"
require "uri"
class RedisWorker < SimpleWorker::Base
merge_gem "redis"
attr_accessor :redis_connection
def run
log "\nRunning RedisWorker..."
# For parsing URL's from Redis to Go
# This will be modified to include an input for "raw" connection data
url = URI.parse(@redis_connection)
log "\nConnecting to Redis..."
redis = Redis.new(:host => url.host, :port => url.port, :password => url.password)
log "Connected.\n\n"
# Basic operations, although you can do any Redis command here you want
# SET
result = redis.set("price:type", "fresh")
log "Set op for \"prince:type\" returned #{result}"
# GET
result = redis.get("prince:type")
log "Set op for \"prince:type\" returned #{result}"
# DELETE
result = redis.del("prince:type")
log "Del op for \"prince:type\" returned #{result}"
log "\nFinished processing RedisWorker.\n\n"
end
end