diff options
author | Urban Müller | 2018-06-21 16:42:32 +0200 |
---|---|---|
committer | Urban Müller | 2018-06-21 16:43:32 +0200 |
commit | 3dabbbd5325c9fad9582cd44b1da68dece78eaa0 (patch) | |
tree | 92d951b948f0e01dc6b7ae3f11b9c03034edb69a /test/it_cache.t | |
parent | 455b15f7a850a58ef667ad170732769043eb1522 (diff) | |
download | itools-3dabbbd5325c9fad9582cd44b1da68dece78eaa0.tar.gz itools-3dabbbd5325c9fad9582cd44b1da68dece78eaa0.tar.bz2 itools-3dabbbd5325c9fad9582cd44b1da68dece78eaa0.zip |
no reason for different naming
Diffstat (limited to 'test/it_cache.t')
-rwxr-xr-x | test/it_cache.t | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/it_cache.t b/test/it_cache.t new file mode 100755 index 0000000..8f804d4 --- /dev/null +++ b/test/it_cache.t @@ -0,0 +1,49 @@ +#!/www/server/bin/php +<?php + +# test array_based process cache +it_cache::put('it_cache_t', 42); +is(it_cache::get('it_cache_t'), 42, "cache put number"); + +it_cache::put('it_cache_t', false); +is(it_cache::get('it_cache_t'), false, "cache get number"); + +it_cache::put('it_cache_t', array(2)); +is(it_cache::get('it_cache_t'), array(2), "cache put/get array"); + + +# test non-distributed apc cache +it_cache::put('it_cache_t', 42); +unset($GLOBALS['it_cache_local']); +is(it_cache::get('it_cache_t'), 42, "local put/get number"); + +it_cache::put('it_cache_t', false); +unset($GLOBALS['it_cache_local']); +is(it_cache::get('it_cache_t'), false, "local put/get false"); + +it_cache::put('it_cache_t', array(2)); +unset($GLOBALS['it_cache_local']); +is(it_cache::get('it_cache_t'), array(2), "local put/get array"); + +is(it_cache::get('it_cache_t'.rand(1, 1000)), null, "local get unknown key"); + + +# test distributed memcache +$GLOBALS['debug_aslive'] = 1; + +it_cache::put('it_cache_d', 42, array('distributed' => 1)); +it_cache::put('it_cache_d', 0); +unset($GLOBALS['it_cache_local']); +is(intval(it_cache::get('it_cache_d', array('distributed' => 1))), 42, "distributed put/get number"); + +it_cache::put('it_cache_d', false, array('distributed' => 1)); +it_cache::put('it_cache_d', 1); +unset($GLOBALS['it_cache_local']); +is(boolval(it_cache::get('it_cache_d', array('distributed' => 1))), false, "distributed put/get false"); + +it_cache::put('it_cache_d', array(2), array('distributed' => 1)); +it_cache::put('it_cache_d', 0); +unset($GLOBALS['it_cache_local']); +is(it_cache::get('it_cache_d', array('distributed' => 1)), array(2), "distributed put/get array"); + +is(it_cache::get('it_cache_d'.rand(1, 1000), array('distributed' => 1)), null, "distributed get unknown key"); |