Compare commits

...

12 Commits
2.8.5 ... v2

Author SHA1 Message Date
Jerry
d3d64c8f06 fix class empty caused bug 2023-06-13 15:31:51 +08:00
crazywhalecc
f0cba01bd7 update to 2.8.9, fix ergodic order via #365 2023-06-12 21:19:17 +08:00
crazywhalecc
ea83ea2cce update to 2.8.9, fix light cache wrong 2023-06-12 21:19:17 +08:00
Jerry Ma
21f310852a update version to 2.8.8 2023-06-05 22:48:36 +08:00
Wang
6173cf2e37 Update LightCacheInside.php 2023-06-05 21:00:31 +08:00
Wang
4791099a78 Update global.php 2023-06-05 21:00:05 +08:00
Wang
9d1952f5f8 add bool type support for LightCache (#325) 2023-03-03 21:58:40 +08:00
Jerry
6543574695 update version to 2.8.7 2023-02-13 21:04:01 +08:00
Wang
5b1c771a2d 为键名使用强制类型转换string
使用数字作为键名时set()成功保存 但是停止框架后再启动框架数据落地恢复时报错类型不符合
Fatal error: Uncaught TypeError: Swoole\Table::set(): Argument #1 ($key) must be of type string, int given in zhamao/vendor/zhamao/framework/src/ZM/Store/LightCache.php:81
2023-02-13 21:04:01 +08:00
sunxyw
29d7d07c8e increment build number (build 480) 2023-01-26 21:59:27 +08:00
Wang
e85e1e57b1 init database in task worker (#271) 2023-01-24 12:11:41 +08:00
crazywhalecc
90a4c6803e update 2.0 docs 2022-12-31 16:54:03 +08:00
8 changed files with 34 additions and 8 deletions

View File

@@ -50,6 +50,8 @@ $config['runtime'] = [
],
'namespace' => [],
],
'inside_table_size' => 65536 // 内部表字符串最大长度需要2的倍数
// 正常不要低于65536如果群数量过多可能出现会size不够。若swoole日志出现WARNING TableRow::set_value(): [key=wait_api,field=value]string value is too long可以将该值往大设置。
];
/* 轻量字符串缓存,默认开启 */

View File

@@ -1,7 +1,7 @@
const apiConfig = require('./api')
module.exports = {
title: '炸毛框架',
title: '炸毛框架v2 旧版)',
description: '一个高性能聊天机器人 + Web 框架',
theme: 'antdocs',
markdown: {
@@ -34,7 +34,7 @@ module.exports = {
{ text: 'API', link: '/api/' },
{ text: 'FAQ', link: '/faq/' },
{ text: '更新日志', link: '/update/v2/' },
{ text: '炸毛框架 v1', link: 'https://docs-v1.zhamao.xin/' }
{ text: '炸毛框架 v3最新版', link: 'https://framework.zhamao.xin/' }
],
sidebar: {
'/guide/': [

View File

@@ -1 +1 @@
framework.zhamao.me
docs-v2.zhamao.me

View File

@@ -105,6 +105,8 @@ class AnnotationParser
}
*/
// 保留ergodic注解
$append_ergodics = [];
// 生成主树
$this->annotation_map[$v]['class_annotations'] = $class_annotations;
$this->annotation_map[$v]['methods'] = $methods;
@@ -120,7 +122,8 @@ class AnnotationParser
foreach (($this->annotation_map[$v]['methods'] ?? []) as $method) {
$copy = clone $vs;
$copy->method = $method->getName();
$this->annotation_map[$v]['methods_annotations'][$method->getName()][] = $copy;
$append_ergodics[$method->getName()][] = $copy;
// $this->annotation_map[$v]['methods_annotations'][$method->getName()][] = $copy;
}
}
@@ -139,6 +142,13 @@ class AnnotationParser
$inserted = [];
// 预处理将Class的ergodic注解拼接到每个方法的注解列表前面且按照顺序修复 #365
foreach (($this->annotation_map[$v]['methods_annotations'] ?? []) as $method_name => $annos) {
if (isset($append_ergodics[$method_name])) {
$this->annotation_map[$v]['methods_annotations'][$method_name] = array_merge($append_ergodics[$method_name], $annos);
}
}
// 预处理3处理每个函数上面的特殊注解就是需要操作一些东西的
foreach (($this->annotation_map[$v]['methods_annotations'] ?? []) as $method_name => $methods_annotations) {
foreach ($methods_annotations as $method_anno) {

View File

@@ -28,9 +28,9 @@ use ZM\Exception\InitException;
class ConsoleApplication extends Application
{
public const VERSION_ID = 479;
public const VERSION_ID = 480;
public const VERSION = '2.8.5';
public const VERSION = '2.8.10';
private static $obj;

View File

@@ -130,6 +130,15 @@ class OnWorkerStart implements SwooleEvent
Framework::saveProcessState(ZM_PROCESS_TASKWORKER, $server->worker_pid, ['worker_id' => $worker_id]);
try {
Framework::$server = $server;
$this->initMySQLPool();
$redis = ZMConfig::get('global', 'redis_config');
if ($redis !== null && $redis['host'] != '') {
if (!extension_loaded('redis')) {
Console::error(zm_internal_errcode('E00029') . "Can not find redis extension.\n");
} else {
ZMRedisPool::init($redis);
}
}
$this->loadAnnotations();
Console::success('TaskWorker #' . $server->worker_id . ' started');
} catch (Exception $e) {

View File

@@ -75,7 +75,7 @@ class LightCache
} else {
return false;
}
$result = self::$kv_table->set($k, [
$result = self::$kv_table->set((string) $k, [
'value' => $value,
'expire' => $v['expire'],
'data_type' => $data_type,
@@ -188,6 +188,9 @@ class LightCache
$data_type = '';
} elseif (is_int($value)) {
$data_type = 'int';
} elseif (is_bool($value)) {
$data_type = 'bool';
$value = json_encode($value);
} else {
throw new LightCacheException('E00048', 'Only can set string, array and int');
}

View File

@@ -6,6 +6,7 @@ namespace ZM\Store;
use Exception;
use Swoole\Table;
use ZM\Config\ZMConfig;
use ZM\Exception\LightCacheException;
use ZM\Exception\ZMException;
@@ -17,7 +18,8 @@ class LightCacheInside
public static function init(): bool
{
try {
self::createTable('wait_api', 3, 65536);
$size = ZMConfig::get('global', 'runtime')['inside_table_size'] ?? 65536;
self::createTable('wait_api', 3, $size);
self::createTable('connect', 3, 64); // 用于存单机器人模式下的机器人fd的
self::createTable('static_route', 64, 256); // 用于存储
self::createTable('light_array', 8, 512, 0.6);