Skip to content

cinling/php-ext-lib

Repository files navigation

cinling/ext-lib

简体中文版

Packagist license Packagist version GitHub last commit

Install

composer require "cinling/ext-lib"

Document


Service

  • Encapsulation of a function
  • Provides configurable parameters

FileCacheService

  • Save data to file
Config
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
Example

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

LogService

  • Output the log and save it in the log file
Config
name type note default
path string Log file save path ./runtime/cin-log
fileMaxSize string Log file max bytes 2MB
Example
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...


Util

  • Provides encapsulation of static methods
  • It can be inserted by trait

ArrayUtil

toArray($attrs): array

Convert $attrs to an array。 $attrs can be an array, an object, a BaseVo derived class, or any collation of the above

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages