Compare commits

..

No commits in common. "a2cfab55bceef3d1769fec4a146d23b428788d0c" and "d615ebdbd96cb6af071462c72818946bff46d732" have entirely different histories.

3 changed files with 3 additions and 46 deletions

View File

@ -29,22 +29,6 @@ class VolatileState:
return RedisTable(self, table)
class VolatileQueue:
"""Quick and dirty volatile queue-like redis wrapper"""
def __init__(self, key, **redis_args):
self.rdb = redis.Redis(**redis_args)
self.key = key
def put(self, item):
self.rdb.sadd(self.key, umsgpack.dumps(item))
def get(self):
v = self.rdb.spop(self.key)
if v:
return umsgpack.loads(v)
class VolatileBooleanState:
"""Quick and dirty volatile dict-like redis wrapper for boolean values"""

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="hexlib",
version="1.26",
version="1.24",
description="Misc utility methods",
author="simon987",
author_email="me@simon987.net",

View File

@ -1,5 +1,5 @@
from unittest import TestCase
from hexlib.db import VolatileState, VolatileBooleanState, VolatileQueue
from hexlib.db import VolatileState, VolatileBooleanState
class TestVolatileState(TestCase):
@ -23,7 +23,7 @@ class TestVolatileState(TestCase):
s["b"]["3"] = 3
s["b"]["4"] = 4
self.assertEqual(sum(v for k, v in s["b"]), 10)
self.assertEqual(sum(v for k,v in s["b"]), 10)
def test_int_key(self):
s = VolatileState(prefix="test2")
@ -68,30 +68,3 @@ class TestVolatileBoolState(TestCase):
self.assertTrue(s["c"]["1"])
del s["c"]["1"]
self.assertFalse(s["c"]["1"])
class TestVolatileQueue(TestCase):
def test_simple(self):
s = VolatileQueue(key="test5")
s.put("test")
item = s.get()
self.assertTrue(item == "test")
def test_dict(self):
s = VolatileQueue(key="test5")
s.put({"a": 1})
item = s.get()
self.assertTrue(item["a"] == 1)
def test_int(self):
s = VolatileQueue(key="test5")
s.put(123)
item = s.get()
self.assertTrue(item == 123)