定制 akeb/cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

akeb/cache

Composer 安装命令:

composer require akeb/cache

包简介

README 文档

README

Install

composer project akeb/cache

Composer config

{
    "require": {
        "akeb/cache": "^1.1.6"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/AKEB/Framework-AKEB-cache"
        }
    ]
}

or

composer require akeb/cache

If you use memcached

global $CACHE_SERVERS;
$CACHE_SERVERS = [
    'default' => ['host'=>'localhost', 'port' => 11211]
];

require_once("../vendor/autoload.php");

If you use FileCache

define('USE_FILE_CACHE', true); // Forcing the use of the file cache

define('PATH_CACHE', '/opt/www/cache/'); // Cache file directory

require_once("../vendor/autoload.php");

Example use Cache

Memcached cache

global $CACHE_SERVERS;
$CACHE_SERVERS = [
    'default' => ['host'=>'localhost', 'port' => 11211], // Description memcached servers
];
require_once("../vendor/autoload.php");

$dateString = '';

$cache = new \Cache('testDate','default'); // Init Cache Object with name "testDate"

if (!$cache->isValid() && $cache->tryLock()) { // If cache not valid and we can lock cache
    // Do something
    $dateString = date("Y-m-d H:i:s", time());

    $cache->update($dateString,600); // Update cache data
    $cache->freeLock(); // Free lock
} else { // Cache valid, or we can't lock cache
    $dateString = $cache->get(); // get data from cache
}

echo $dateString.PHP_EOL;

File cache

define('PATH_CACHE', './tmp/'); // Cache file directory

require_once("../vendor/autoload.php");

$dateString = '';

$cache = new \Cache('testDate','default'); // Init Cache Object with name "testDate"

if (!$cache->isValid() && $cache->tryLock()) { // If cache not valid and we can lock cache
    // Do something
    $dateString = date("Y-m-d H:i:s", time());

    $cache->update($dateString,600); // Update cache data
    $cache->freeLock(); // Free lock
} else { // Cache valid, or we can't lock cache
    $dateString = $cache->get(); // get data from cache
}

echo $dateString.PHP_EOL;

See the examples folder for more details.

Run Unit Tests

./dockerTest.sh

统计信息

  • 总下载量: 1.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固