update to build 417

This commit is contained in:
2021-09-01 14:14:00 +08:00
parent a13c4628f5
commit 229778ebf9
50 changed files with 1376 additions and 207 deletions

View File

@@ -9,6 +9,7 @@ use Swoole\Table;
use ZM\Annotation\Swoole\OnSave;
use ZM\Console\Console;
use ZM\Event\EventDispatcher;
use ZM\Exception\LightCacheException;
use ZM\Exception\ZMException;
use ZM\Framework;
use ZM\Utils\Manager\ProcessManager;
@@ -86,7 +87,7 @@ class LightCache
* @throws ZMException
*/
public static function get(string $key) {
if (self::$kv_table === null) throw new ZMException(zm_internal_errcode("E00048") . "not initialized LightCache");
if (self::$kv_table === null) throw new LightCacheException("E00048", "not initialized LightCache");
self::checkExpire($key);
$r = self::$kv_table->get($key);
return $r === false ? null : self::parseGet($r);
@@ -98,7 +99,7 @@ class LightCache
* @throws ZMException
*/
public static function getExpire(string $key) {
if (self::$kv_table === null) throw new ZMException(zm_internal_errcode("E00048") . "not initialized LightCache");
if (self::$kv_table === null) throw new LightCacheException("E00048", "not initialized LightCache");
self::checkExpire($key);
$r = self::$kv_table->get($key, "expire");
return $r === false ? null : $r - time();
@@ -111,7 +112,7 @@ class LightCache
* @since 2.4.3
*/
public static function getExpireTS(string $key) {
if (self::$kv_table === null) throw new ZMException(zm_internal_errcode("E00048") . "not initialized LightCache");
if (self::$kv_table === null) throw new LightCacheException("E00048", "not initialized LightCache");
self::checkExpire($key);
$r = self::$kv_table->get($key, "expire");
return $r === false ? null : $r;
@@ -125,7 +126,7 @@ class LightCache
* @throws ZMException
*/
public static function set(string $key, $value, int $expire = -1) {
if (self::$kv_table === null) throw new ZMException(zm_internal_errcode("E00048") . "not initialized LightCache");
if (self::$kv_table === null) throw new LightCacheException("E00048", "not initialized LightCache");
if (is_array($value)) {
$value = json_encode($value, JSON_UNESCAPED_UNICODE);
if (strlen($value) >= self::$config["max_strlen"]) return false;
@@ -138,7 +139,7 @@ class LightCache
$data_type = "bool";
$value = json_encode($value);
} else {
throw new ZMException(zm_internal_errcode("E00049") . "Only can set string, array and int");
throw new LightCacheException("E00049", "Only can set string, array and int");
}
try {
return self::$kv_table->set($key, [
@@ -158,7 +159,7 @@ class LightCache
* @throws ZMException
*/
public static function update(string $key, $value) {
if (self::$kv_table === null) throw new ZMException(zm_internal_errcode("E00048") . "not initialized LightCache.");
if (self::$kv_table === null) throw new LightCacheException("E00048", "not initialized LightCache.");
if (is_array($value)) {
$value = json_encode($value, JSON_UNESCAPED_UNICODE);
if (strlen($value) >= self::$config["max_strlen"]) return false;
@@ -168,7 +169,7 @@ class LightCache
} elseif (is_int($value)) {
$data_type = "int";
} else {
throw new ZMException(zm_internal_errcode("E00048") . "Only can set string, array and int");
throw new LightCacheException("E00048", "Only can set string, array and int");
}
try {
if (self::$kv_table->get($key) === false) return false;