承接 webclient/cache-contract 相关项目开发

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

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

webclient/cache-contract

最新稳定版本:v1.0.0

Composer 安装命令:

composer require webclient/cache-contract

包简介

Interface for caching

README 文档

README

Latest Stable Version Total Downloads License PHP

webclient/cache-contract

Cache interface for webclient/ext-cache

Install

composer require webclient/cache-contract:^1.0

Tips and tricks

Split cache storage for settings and responses

You may split cache storage for settings and responses.

implements cache-contract, like it:

<?php

use Webclient\Cache\Contract\CacheInterface;

class SplitCache implements CacheInterface
{
    private CacheInterface $settingsCache;
    private CacheInterface $responsesCache;
    public function __construct(CacheInterface $settingsCache, CacheInterface $responsesCache)
    {
        $this->settingsCache = $settingsCache;
        $this->responsesCache = $responsesCache;
    }

    public function get(string $key) : ?string
    {
        $this->getStorage($key)->get($key);
    }

    public function set(string $key,string $data,?int $ttl = null) : void
    {
        $this->getStorage($key)->get($key, $data, $ttl);
    }

    private function getStorage(string $key): CacheInterface
    {
        if (strpos($key, 'http.settings.') === 0) {
            return $this->settingsCache;
        }
        if (strpos($key, 'http.response.') === 0) {
            return $this->responsesCache;
        }
        throw new InvalidArgumentException('can not define storage');
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固