Commit 165f0503 authored by Maciej Nabozny's avatar Maciej Nabozny

Cache interface updated

parent c5d1cb37
Pipeline #37 failed with stages
in 1 minute and 18 seconds
......@@ -59,11 +59,23 @@ class CacheInterface(object):
def lpop(self, name):
'''
Remove element from list
Remove element from beginning of list
'''
raise Exception('not implemented')
def rpop(self, name):
'''
Remove element from end of list
'''
raise Exception('not implemented')
def lpush(self, name, value):
'''
Insert element at the beginning of the list
'''
raise Exception('not implemented')
def rpush(self, name, value):
'''
Insert element at the end of the list
'''
......@@ -100,4 +112,4 @@ class CacheInterface(object):
raise Exception('not implemented')
def lock(self, name):
raise Exception('not implemented')
\ No newline at end of file
raise Exception('not implemented')
......@@ -55,9 +55,15 @@ class Cache(CacheInterface):
def lpop(self, name):
return self.conn.lpop(name)
def rpop(self, name):
return self.conn.rpop(name)
def lpush(self, name, value):
return self.conn.lpush(name, value)
def rpush(self, name, value):
return self.conn.rpush(name, value)
def lindex(self, name, index):
return self.conn.lindex(name, index)
......@@ -74,4 +80,4 @@ class Cache(CacheInterface):
return self.conn.delete(name)
def lock(self, name):
return self.conn.lock(name)
\ No newline at end of file
return self.conn.lock(name)
......@@ -113,7 +113,7 @@ class Task(Model):
context=self.logger_ctx)
blockers = Cache.lrange('blockers:' + self.cache_key(), 0, Cache.llen('blockers:' + self.cache_key()))
if obj.last_task not in blockers:
Cache.lpush('blockers:' + self.cache_key(), obj.last_task)
Cache.rpush('blockers:' + self.cache_key(), obj.last_task)
obj.last_task = self.cache_key()
else:
obj.last_task = self.cache_key()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment