2020-09-29 15:07:43 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
use ZM\Store\LightCache;
|
|
|
|
|
|
|
|
|
|
class LightCacheTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
public function testCache() {
|
|
|
|
|
LightCache::init([
|
2020-11-03 21:02:24 +08:00
|
|
|
"size" => 2,
|
2020-09-29 15:07:43 +08:00
|
|
|
"max_strlen" => 4096,
|
2020-11-03 21:02:24 +08:00
|
|
|
"hash_conflict_proportion" => 0,
|
|
|
|
|
"persistence_path" => "../composer.json"
|
2020-09-29 15:07:43 +08:00
|
|
|
]);
|
|
|
|
|
//LightCache::set("bool", true);
|
|
|
|
|
$this->assertEquals(true, LightCache::set("2048", 123, 3));
|
|
|
|
|
$this->assertArrayHasKey("2048", LightCache::getAll());
|
|
|
|
|
sleep(3);
|
|
|
|
|
$this->assertArrayNotHasKey("2048", LightCache::getAll());
|
2020-11-03 21:02:24 +08:00
|
|
|
$this->assertEquals("Apache-2.0", LightCache::get("license"));
|
|
|
|
|
$this->assertEquals("zhamao/framework", LightCache::get("name"));
|
|
|
|
|
//$this->assertTrue(LightCache::set("storage", "asdasd", -2));
|
|
|
|
|
//LightCache::savePersistence();
|
2020-09-29 15:07:43 +08:00
|
|
|
}
|
|
|
|
|
}
|