示例#1
0
class Publisher(object):
    def __init__(self, client, buffer_size=10000):
        self.client = client
        self.lru = LRUCache(1500, 1, buffer_size)

    def publish(self, key, value):
        now = time.time()
        val = self.lru.get(key)
        if val and (val + 3) < now:
            return False
        self.lru.put(key, now)
        self.client.publish(key, value)
        return True
示例#2
0
 def __init__(self, client, buffer_size=10000):
     self.client = client
     self.lru = LRUCache(1500, 1, buffer_size)