Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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"
Exemplo n.º 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
Exemplo n.º 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"