承接 genkgo/cache 相关项目开发

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

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

genkgo/cache

最新稳定版本:0.4.3

Composer 安装命令:

composer require genkgo/cache

包简介

README 文档

README

PHP Cache library using mechanisms as originally proposed by Anthony Ferrara.

Credit to Anthony Ferrara.

All the credit for the cache mechanisms go to @ircmaxell. Please go and read his blog post explaining why cache should be implemented this way.

Installation

Requires PHP 5.5 or later. There are no plans to support PHP 5.4 or PHP 5.3. In case this is an obstacle for you, conversion should be no problem. The library is very small.

It is installable and autoloadable via Composer as genkgo/cache.

Quality

Scrutinizer Code Quality Code Coverage Build Status

To run the unit tests at the command line, issue phpunit -c tests/. PHPUnit is required.

This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Getting Started

Create your own adapter

Create an adapter that implements the CacheAdapterInterface. A simple array adapter would look as follows. The array adapter is also shipped with this library.

<?php
namespace My\Namespace;

use Genkgo\Cache\CacheAdapterInterface;

class ArrayAdapter implements CacheAdapterInterface
{
    private $data = [];

    public function set($key, $value)
    {
        $this->data[$key] = $value;
    }

    public function get($key)
    {
        if ($this->exists($key)) {
            return $this->data[$key];
        }
    }

    public function delete($key)
    {
        if ($this->exists($key)) {
            unset($this->data[$key]);
        }
    }

    private function exists($key)
    {
        return isset($this->data[$key]) || array_key_exists($key, $this->data);
    }
}

Inject the adapter

To use your adapter, inject it into another object and start using the api. If you do not want any cache, but your class relies on a cache adapter being there, inject the NullAdapter.

Contributing

  • Found a bug? Please try to solve it yourself first and issue a pull request. If you are not able to fix it, at least give a clear description what goes wrong. We will have a look when there is time.
  • Want to see a feature added, issue a pull request and see what happens. You could also file a bug of the missing feature and we can discuss how to implement it.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-01-22