Exemplo n.º 1
0
def test_cache_namespace(redis_unix_socket_path):
    cache01 = Cache(redis_options={'unix_socket_path': redis_unix_socket_path})
    cache02 = Cache(namespace='test:',
                    redis_options={'unix_socket_path': redis_unix_socket_path})
    assert cache01.set('key', 'value')
    assert cache01.get('key') == 'value'
    assert cache02.get('key') is None
Exemplo n.º 2
0
def test_cache_namespace(redis_unix_socket_path):
    cache01 = Cache(redis_options={'unix_socket_path': redis_unix_socket_path})
    cache02 = Cache(
        namespace='test:',
        redis_options={'unix_socket_path': redis_unix_socket_path})
    assert cache01.set('key', 'value')
    assert cache01.get('key') == 'value'
    assert cache02.get('key') is None
Exemplo n.º 3
0
def test_cache_basic_apis(redis_unix_socket_path):
    cache = Cache(redis_options={'unix_socket_path': redis_unix_socket_path})
    assert cache.get('key') is None
    assert cache.set('key', 'value')
    assert cache.get('key') == 'value'
    assert cache.delete('key')
    assert cache.get('key') is None

    assert cache.get_many('key1', 'key2') == [None, None]
    assert cache.set_many({'key1': 'value1', 'key2': 'value2'})
    assert cache.get_many('key1', 'key2') == ['value1', 'value2']
    assert cache.delete_many('key1', 'key2')
    assert cache.get_many('key1', 'key2') == [None, None]
    assert cache.get_many() == []
    assert cache.set_many({})
    assert cache.delete_many()

    assert cache.get('key') is None
    assert cache.set('key', ['value'])
    assert cache.get('key') == ['value']
    assert cache.get_many('key') == [['value']]
    assert cache.delete('key')
    assert cache.get('key') is None
Exemplo n.º 4
0
def test_cache_basic_apis(redis_unix_socket_path):
    cache = Cache(redis_options={'unix_socket_path': redis_unix_socket_path})
    assert cache.get('key') is None
    assert cache.set('key', 'value')
    assert cache.get('key') == 'value'
    assert cache.delete('key')
    assert cache.get('key') is None

    assert cache.get_many('key1', 'key2') == [None, None]
    assert cache.set_many({'key1': 'value1', 'key2': 'value2'})
    assert cache.get_many('key1', 'key2') == ['value1', 'value2']
    assert cache.delete_many('key1', 'key2')
    assert cache.get_many('key1', 'key2') == [None, None]
    assert cache.get_many() == []
    assert cache.set_many({})
    assert cache.delete_many()

    assert cache.get('key') is None
    assert cache.set('key', ['value'])
    assert cache.get('key') == ['value']
    assert cache.get_many('key') == [['value']]
    assert cache.delete('key')
    assert cache.get('key') is None