示例#1
0
def test_set_multi_expires(mock_cache):
    redis, clock = mock_cache
    cache.set_multi({"foo1": "bar1", "foo2": "bar2"}, expires=60)
    assert cache.get("foo1") == "bar1"
    assert cache.get("foo2") == "bar2"
    clock.set_time(datetime.datetime.now() + datetime.timedelta(seconds=61))
    redis.do_expire()
    assert cache.get("foo1") == None
    assert cache.get("foo2") == None
示例#2
0
def test_set_multi_expires(mock_cache):
    redis, clock = mock_cache
    cache.set_multi({"foo1": "bar1", "foo2": "bar2"}, expires=60)
    assert cache.get("foo1") == "bar1"
    assert cache.get("foo2") == "bar2"
    clock.set_time(datetime.datetime.now() + datetime.timedelta(seconds=61))
    redis.do_expire()
    assert cache.get("foo1") == None
    assert cache.get("foo2") == None
示例#3
0
def test_set_multi_prefix(mock_cache):
    redis, clock = mock_cache
    cache.set_multi({"foo1": "bar1", "foo2": "bar2"}, key_prefix="test_")
    assert cache.get("test_foo1") == "bar1"
    assert cache.get("test_foo2") == "bar2"
    assert cache.get("foo1") == None
示例#4
0
def test_set_multi(mock_cache):
    redis, clock = mock_cache
    cache.set_multi({"foo1": "bar1", "foo2": "bar2"})
    assert cache.get("foo1") == "bar1"
    assert cache.get("foo2") == "bar2"
示例#5
0
def test_set_multi_prefix(mock_cache):
    redis, clock = mock_cache
    cache.set_multi({"foo1": "bar1", "foo2": "bar2"}, key_prefix="test_")
    assert cache.get("test_foo1") == "bar1"
    assert cache.get("test_foo2") == "bar2"
    assert cache.get("foo1") == None
示例#6
0
def test_set_multi(mock_cache):
    redis, clock = mock_cache
    cache.set_multi({"foo1": "bar1", "foo2": "bar2"})
    assert cache.get("foo1") == "bar1"
    assert cache.get("foo2") == "bar2"