composer require "cinling/ext-lib"
- Service
- Util
- ArrayUtil
- ConsoleUtil
- CronParseUtil
- DevelUtil
- EncryptUtil
- EnvUtil
- ExcelUtil
- FileUtil
- GeoUtil
- Value Object(vo)...
- Enums...
- Encapsulation of a function
- Provides configurable parameters
- Save data to file
name | type | note | default |
---|---|---|---|
path | string | Cache file save path | ./runtime/cin-cache |
pathDeeps | int | Path depth | 2 |
pathUnitLen | int | The number of characters in a single directory | 2 |
Set cache
use cin\extLib\services\FileCacheService;
FileCacheService::getIns()->set("CacheKeyCin", "cin");
Get cache
use cin\extLib\services\FileCacheService;
$srv = FileCacheService::getIns();
$srv->set("CacheKeyCin", "cin");
$value = FileCacheService::getIns()->get("CacheKeyCin");
echo $value; // output: cin
Delete cache
use cin\extLib\services\FileCacheService;
$srv = FileCacheService::getIns();
$srv->set("CacheKeyCin", "cin");
$srv->del("CacheKeyCin");
$value = $srv->get("CacheKeyCin");
echo $value; // output: null
Set cache with expiration time
use cin\extLib\services\FileCacheService;
FileCacheService::getIns()->set("CacheKeyCin", "cin", 3600); // expire after 3600s
- Output the log and save it in the log file
name | type | note | default |
---|---|---|---|
path | string | Log file save path | ./runtime/cin-log |
fileMaxSize | string | Log file max bytes | 2MB |
use cin\extLib\services\LogService;
LogService::getIns()->info("Content...", "Title");
output in runtime/cin-log/cin.log
:
[2021-01-18 14:54:31 INFO Title] Content...
- Provides encapsulation of static methods
- It can be inserted by
trait
Convert $attrs
to an array。
$attrs
can be an array
, an object
, a BaseVo
derived class, or any collation of the above