def test_cache(): ax = DummyA(1, 10) bx = DummyB(2, 2) cx = DummyC(3, 3) assert f(ax, bx, cx) == 50 assert h(bx, cx) == 5 assert score(ax) assert smache.is_fun_fresh(score, ax) == True assert smache.is_fun_fresh(f, ax, bx, cx) == True assert smache.is_fun_fresh(h, bx, cx) == True DummyB.update(0, {}) assert smache.is_fun_fresh(score, ax) == False assert smache.is_fun_fresh(f, ax, bx, cx) == True assert smache.is_fun_fresh(h, bx, cx) == True DummyA.update(1, {}) assert smache.is_fun_fresh(score, ax) == False assert smache.is_fun_fresh(f, ax, bx, cx) == False assert smache.is_fun_fresh(h, bx, cx) == True DummyB.update(2, {}) assert smache.is_fun_fresh(score, ax) == False assert smache.is_fun_fresh(f, ax, bx, cx) == False assert smache.is_fun_fresh(h, bx, cx) == False
def test_write_through_with_collection_wide_subscription(): assert slash() == 'hello/hihi' DummyA.update(2, {'value': 'lol'}) execute_all_jobs(worker_queue, redis_con) assert smache.function_cache_value(slash) == 'hello/lol'
def test_write_through(): ax = DummyA(1, 'hello') bx = DummyB(1, 'world') assert hyphen(ax, bx) == 'hello - world' assert slash() == 'hello/hihi' assert smache.is_fun_fresh(hyphen, ax, bx) == True DummyA.update(1, {'value': 'wtf'}) execute_all_jobs(worker_queue, redis_con) assert smache.is_fun_fresh(hyphen, ax, bx) == True assert smache.function_cache_value(hyphen, ax, bx) == 'wtf - world'
def test_write_through(): ax = DummyA(1, 'hello') bx = DummyB(1, 'world') assert hyphen(ax, bx) == 'hello - world' assert slash() == 'hello/hihi' assert smache.is_fun_fresh(hyphen, ax, bx) == True DummyA.update(1, {'value': 'wtf'}) execute_all_jobs(worker_queue, redis_con) assert smache.is_fun_fresh(hyphen, ax, bx) == True assert smache.function_cache_value( hyphen, ax, bx ) == 'wtf - world'