-
Notifications
You must be signed in to change notification settings - Fork 0
Changing the Prefix of the Redis List
waawal edited this page Apr 9, 2012
·
2 revisions
HotQueue automatically assigns you the "hotqueue"-prefix to your keys. That means that the Redis-list that gets produced will be accessible by hotqueue:myqueue if myqueue is the name of your queue. Sometimes it can be necessary to override this behaviour.
This can be done by passing the prefix argument to the bottle-plugin. You will also have to override the key_for_name function in the hotqueue module.
import bottle
from bottlehotqueue import HotQueuePlugin
app = bottle.Bottle()
hotqueue = HotQueuePlugin(keyword="myhotqueue", prefix="myprefix")
app.install(hotqueue)
HotQueue wasn't designed for this so you will have to override the key_for_name function of the HotQueue module. Below is a consumer that does just that.
import json
import hotqueue
PREFIX = "myprefix"
hotqueue.key_for_name = lambda x: ''.join([PREFIX, ":", x])
queue = hotqueue.HotQueue("myqueue", serializer=json)
for item in queue.consume():
print item