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

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

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

gameplayjdk/php-file-cache

Composer 安装命令:

composer require gameplayjdk/php-file-cache

包简介

Low-level, file based cache using var_export() and some magic. Optionally PSR-16 compliant.

README 文档

README

Low-level, file based cache using brick/varexporter. Optionally PSR-16 compliant.

Installation

composer require gameplayjdk/php-file-cache

Usage

<?php

require __DIR__ . '/vendor/autoload.php';

use Cache\Cache;
use Cache\Psr16\Cache as Psr16Cache;

$key = 'an_example_key';

// Create cache object.
$cache = new Cache(__DIR__ .  '/cache');

// Set something to the cache.
$value = 'some string value';
echo 'value set to the cache is ' . $value;
echo PHP_EOL;
$cache->set($key, $value);

// Get something from the cache.
$value = $cache->get($key);
echo 'value got from the cache is ' . $value;
echo PHP_EOL;

// Check if something is expired in cache.
$expired = $cache->exp($key, strtotime('+1 Minute'));
echo $expired ? 'expired' : 'not expired';
echo PHP_EOL;

// Check if something is present in the cache.
$present = $cache->has($key);
echo $present ? 'present' : 'not present';
echo PHP_EOL;

// Delete something from the cache.
$cache->del($key);
echo 'deleted';
echo PHP_EOL;

// Check if something is present in the cache. This time after deleting it.
$present = $cache->has($key);
echo $present ? 'still present' : 'no more present';
echo PHP_EOL;

// Caching an object.
echo PHP_EOL;

/**
 * Class Something
 */
class Something {

    /**
     * @var mixed|null
     */
    public $var1 = null;

    /**
     * @var mixed|null
     */
    public $var2 = null;

    /**
     * This is optional.
     * 
     * @param array $an_array
     * @return Something
     */
    public static function __set_state($an_array)
    {
        $obj = new static();
        $obj->var1 = $an_array['var1'];
        $obj->var2 = $an_array['var2'];
        return $obj;
    }
}

// Set something to the cache.
$obj = new Something();
$obj->var1 = 1;
$obj->var2 = $value;
echo 'value set to the cache is ' . print_r($obj, true);
echo PHP_EOL;
$cache->set($key, $obj);

// Get something from the cache.
$obj = $cache->get($key);
echo 'value got from the cache is ' . print_r($obj, true);
echo PHP_EOL;

// Check if something is present in the cache.
$present = $cache->has($key);
echo $present ? 'present' : 'not present';
echo PHP_EOL;

// Clear the whole cache.
$cache->clr();
echo 'cleared';
echo PHP_EOL;

// Check if something is present in the cache. This time after clearing the whole cache..
$present = $cache->has($key);
echo $present ? 'still present' : 'no more present';
echo PHP_EOL;

// The PSR-16 compliant adapter can also be used. It takes a cache instance as constructor argument.
$psrCache = new Psr16Cache($cache);
// Set the cache expiry time to one minute.
$psrCache->setCacheExpiryTime(strtotime('+1 Minute', 0));

// Now the object can be used using the standard interface methods.
echo PHP_EOL;

// The PSR-16 compliant cache also supports sanitizing keys before using them.
// It is generally advised to use the adapter class.

License

It's MIT.

gameplayjdk/php-file-cache 适用场景与选型建议

gameplayjdk/php-file-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.87k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 gameplayjdk/php-file-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gameplayjdk/php-file-cache 我们能提供哪些服务?
定制开发 / 二次开发

基于 gameplayjdk/php-file-cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-18