Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Commit

Permalink
革命性更新,优化性能,缓存架构,模型架构,修补注释,等细节
Browse files Browse the repository at this point in the history
  • Loading branch information
2daye committed Feb 5, 2020
1 parent 311ffa7 commit 707cf6b
Show file tree
Hide file tree
Showing 20 changed files with 1,344 additions and 615 deletions.
8 changes: 4 additions & 4 deletions core/CoolPhp.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ public static function multi_run($routing_module, $routing_controller, $routing_
//获取使用什么方法
$controller_action = $routing_methods;
//判断模块存在吗
if (is_dir($module) && $routing_module != 'general') {
if (is_dir($module) && $routing_module != 'common') {
//判断控制器文件存在吗
if (is_file($controller_class_file)) {
//控制器存在直接new出控制器
$controller = new $controller_class();
//method_exists()判断控制器中的一个方法是否存在
if (method_exists($controller, $controller_action)) {
//把模块/控制器/操作方法名称传入Request类
$request = Request::get_instance();
$request = Request::getInstance();
$request->module = $routing_module;
$request->controller = $routing_controller;
$request->methods = $routing_methods;
//方法存在执行这个方法
//方法存在,就执行这个方法
$controller->$controller_action();
//打上日志,执行了什么控制器和控制器的什么方法
//\core\plugin\Log::log('module->' . $routing_module . ' controller->' . $routing_controller . ' methods->' . $routing_methods);
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function single_run($routing_controller, $routing_methods)
//method_exists()判断控制器中的一个方法是否存在
if (method_exists($controller, $controller_action)) {
//把控制器/操作方法名称传入Request类
$request = Request::get_instance();
$request = Request::getInstance();
$request->controller = $routing_controller;
$request->methods = $routing_methods;
//方法存在执行这个方法
Expand Down
14 changes: 8 additions & 6 deletions core/config/cache.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
return array(
//CACHE缓存方式 支持file和redis
'CACHE_WAY' => 'redis',
/**
* 框架缓存配置文件
* 支持File和Redis
*/
return [
'CACHE_WAY' => 'file',
'FILE_CACHE' => [
'PATH' => '/core/cache/file_cache/'
],
'REDIS_CACHE' => [
'IP' => '127.0.0.1',
'PORT' => 6379,
'PASSWORD' => '123456'
],
'MEMCACHED_CACHE' => []
);
]
];
9 changes: 9 additions & 0 deletions core/config/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* 框架公共配置
*/
return [
'ENCRYPTION' => [
'KEY' => '南边来了他大大伯子家的大搭拉尾巴耳朵狗'
]
];
8 changes: 6 additions & 2 deletions core/config/db.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
return array(
/**
* 框架数据库配置文件
* MySql数据库
*/
return [
'DB_HOST' => 'localhost',
'DB_USER' => 'root',
'DB_NAME' => 'hahaha',
'DB_PASSWORD' => '123456',
'DB_PORT_NUMBER' => '3306'
);
];
11 changes: 8 additions & 3 deletions core/config/log.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php
return array(
/**
* 框架日志配置文件
* 'LOG_FOLDER' => 'YmdH'
* YmdH 表示1个小时分出一个log日志文件将,
* 这样可以避免高并发的时候,出现非常大的log日志。
*/
return [
'LOG_DRIVE' => 'file',
'LOG_PATH' => '/core/log/',
/*YmdH 表示1个小时分出一个log日志文件将,这样可以避免高并发的时候,出现非常大的log日志*/
'LOG_FOLDER' => 'YmdH'
);
];
7 changes: 5 additions & 2 deletions core/config/routing.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
return array(
/**
* 框架路由配置文件
*/
return [
//是否开启多模块设计
'APP_MULTI_MODULE' => true,
//是否开启URL中控制器和操作名的自动转换
Expand All @@ -16,4 +19,4 @@
],
//框架路径
'FP' => '/'
);
];
192 changes: 189 additions & 3 deletions core/plugin/Cache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct($way = null)
//判断是否有缓存方式存入,没有就用配置的方法
$drive = $way != null ? $way : \core\plugin\Config::get('cache', 'CACHE_WAY');
//call_user_func() 方法可以把字符串当方法调用
self::$class = call_user_func('\core\plugin\Drive\cache\\' . $drive . '::get_instance');
self::$class = call_user_func('\core\plugin\Drive\cache\\' . $drive . '::getInstance');
}

/**
Expand Down Expand Up @@ -60,9 +60,9 @@ public function delete($key)
* @param string $key //key名,默认*获取全部的key
* @return array
*/
public function get_key($key = '*')
public function getKey($key = '*')
{
return self::$class->get_key($key);
return self::$class->getKey($key);
}

/**
Expand All @@ -86,4 +86,190 @@ public function reduce($key, $value = null)
{
return self::$class->reduce($key, $value);
}

/**
* 插入数据到列表
* @param $key //列表名
* @param $value //要插入的数据
* @param string $type //从列表的那一侧插入,默认左侧
* @return bool|mixed
*/
public function insertList($key, $value, $type = 'l')
{
return self::$class->insertList($key, $value, $type);
}

/**
* 获取列表长度
* @param $key //列表名
* @return int
*/
public function getListLength($key)
{
return self::$class->getListLength($key);
}

/**
* 设置哈希缓存
* @param $hash
* @param $key
* @param $value
* @return int
*/
public function setHash($hash, $key, $value)
{
return self::$class->setHash($hash, $key, $value);
}

/**
* 获取哈希
* @param $hash
* @param $key
* @return string
*/
public function getHash($hash, $key)
{
return self::$class->getHash($hash, $key);
}

/**
* 获取哈希长度
* @param $hash
* @return int
*/
public function getHashLength($hash)
{
return self::$class->getHashLength($hash);
}

/**
* 删除哈希中的key
* @param $hash
* @param $key
* @return mixed
*/
public function delecHashKey($hash, $key)
{
return self::$class->delecHashKey($hash, $key);
}

/**
* 获取哈希全部的键
* @param $hash
* @return array
*/
public function getHashAllKey($hash)
{
return self::$class->getHashAllKey($hash);
}

/**
* 获取哈希全部的值
* @param $hash
* @return array
*/
public function getHashAllValue($hash)
{
return self::$class->getHashAllValue($hash);
}

/**
* 获取哈希全部的键和值
* @param $hash
* @return array
*/
public function getHashAll($hash)
{
return self::$class->getHashAll($hash);
}

/**
* 判断哈希是否存在键域
* @param $hash
* @param $key
* @return bool
*/
public function hashExistKey($hash, $key)
{
return self::$class->hashExistKey($hash, $key);
}

/**
* 增加哈希的值
* @param $hash
* @param $key
* @param $number
* @return int
*/
public function increaseHashValue($hash, $key, $number)
{
return self::$class->increaseHashValue($hash, $key, $number);
}

/**
* 插入无序集合
* 无序集合,每次插入都可能会弄乱排序
* @param $key
* @param $value
* @return mixed
*/
public function insertGroup($key, $value)
{
return self::$class->insertGroup($key, $value);
}

/**
* 获取无序集合
* @param $key
* @return array
*/
public function getGroup($key)
{
return self::$class->getGroup($key);
}

/**
* 插入有序集合
* 有序集合,每次插入都根据score分数,进行排序
* @param $key
* @param $score
* @param $value
* @return int
*/
public function insertOrderlyGroup($key, $score, $value)
{
return self::$class->insertOrderlyGroup($key, $score, $value);
}

/**
* 开启事务
* @return \Redis
*/
public function openTransaction()
{
return self::$class->openTransaction();
}

/**
* 提交事务
* @return bool
*/
public function commitTransaction()
{
return self::$class->commitTransaction();
}

/**
* 监视key
* @param $key
*/
public function monitorKey($key)
{
return self::$class->monitorKey($key);
}

public function getList($key, $s = 0, $e = -1)
{
return self::$class->getList($key, $s, $e);
}
}
Loading

0 comments on commit 707cf6b

Please sign in to comment.