def test_mutable_values_with_writeback(redis):
    shelf = RedisShelf(redis=redis, writeback=True)
    shelf["list"] = [1, 2, 3]
    shelf["list"].append(4)

    # before syncing, old value is in Redis.
    assert [1, 2, 3] == pickle.loads(redis.get(b"list"))
    shelf.sync()
    assert [1, 2, 3, 4] == pickle.loads(redis.get(b"list"))
예제 #2
0
def test_mutable_values_with_writeback(redis):
    shelf = RedisShelf(key_prefix='test', redis=redis, writeback=True)
    shelf.writeback = True
    shelf['list'] = [1, 2, 3]
    shelf['list'].append(4)

    # before syncing, old value is in Redis.
    assert [1, 2, 3] == pickle.loads(redis.get(b'test|list'))
    shelf.sync()
    assert [1, 2, 3, 4] == pickle.loads(redis.get(b'test|list'))
def shelf(redis):
    return RedisShelf(redis=redis, key_prefix="test")
예제 #4
0
def shelf(redis):
    return RedisShelf(redis=redis)