承接 silmaralberti/php-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

silmaralberti/php-cache

最新稳定版本:1.1.2

Composer 安装命令:

composer require silmaralberti/php-cache

包简介

README 文档

README

extensible and flexible php cache lib.

Install to project

composer require silmaralberti/php-cache

Docs

Use example

// set redis adapter connection
$redisConnectionParams = [
    'host' => 'host.docker.internal'
];

$serializer = new IgBinaryLib();
$redisAdapter = new RedisAdapter($redisConnectionParams);
$hash = new HashKeyLib();

$testSettings = new PhpCacheSettingsModel(
    $redisAdapter,
    $serializer,
    $hash
);

$phpCache = new PhpCache($testSettings);
$queryContent = [
    'keyA' => 'keyContentA',
    'keyB' => 'keyContentB'
];

$valueContent = [
    'valueA' => 'contentA',
    'valueB' => 'contentB'
];
$valueCount = $phpCache->increase($queryContent, 1);
// $valueCount 1 if first call

$successOnSave = $phpCache->set($queryContent, $valueContent);
// $successOnSave true if success else false

$cachedValueContent = $phpCache->get($queryContent);
// false if not found in cache 
// $cachedValueContent is equal $valueContent

Serializer Classes

  • IgBinaryLib
  • DefaultSerializerLib

Adapter Class

  • RedisAdapter

KeyGenerator Lib

  • HashKeyLib

PhpCache Methods

increase()

increment and return key value

get()

load cache data

set()

storage cache data

cacheFunction()

get response of function from cache or call function and store result on cache

example:

$serializer = new IgBinaryLib();
$redisAdapter = new RedisAdapter($redisConnectionParams);
$hash = new HashKeyLib();

$testSettings = new PhpCacheSettingsModel(
    $redisAdapter,
    $serializer,
    $hash
);

$phpCache = new PhpCache($testSettings);

$testValue = 'storedOnCacheValue';

$result = $phpCache->cacheFunction(
    function ($testValue) {
        return $testValue;
    },
    [$testValue],
    'functionExample'
);

echo $result;
// print 'storedOnCacheValue';

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固