承接 temant/cache-manager 相关项目开发

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

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

temant/cache-manager

Composer 安装命令:

composer require temant/cache-manager

包简介

A flexible caching system with multiple adapters (Redis, Memcached, File).

README 文档

README

Build Status Coverage Status License PHPStan

A flexible caching system that supports multiple adapters, including Redis, Memcached, and File-based caching. This library is PSR-6 compatible, making it easy to integrate with existing PHP applications.

Features

  • Redis Cache Adapter: High-performance caching using Redis.
  • Memcached Cache Adapter: Lightweight and distributed caching with Memcached.
  • Single-File PHP Cache Adapter: A simple file-based cache stored in a single PHP file.
  • Flexible Cache Manager: Seamlessly switch between cache adapters.
  • PSR-6 Compliant: Compatible with any PSR-6-based applications.

Installation

  1. Install via Composer:

    composer require temant/cache-system
  2. Ensure you have Redis and Memcached installed if using their respective adapters:

    • For Redis: sudo apt install redis-server
    • For Memcached: sudo apt install memcached

Usage

Basic Setup

use Temant\Cache\CacheManager;
use Temant\Cache\Adapter\RedisCacheAdapter;

// Example using Redis adapter
$redisAdapter = new RedisCacheAdapter('127.0.0.1', 6379);
$cacheManager = new CacheManager($redisAdapter);

// Save an item in the cache
$cacheItem = $cacheManager->getItem('my_key');
$cacheItem->set('some_value');
$cacheManager->save($cacheItem);

// Retrieve the item from the cache
$cachedItem = $cacheManager->getItem('my_key');
if ($cachedItem->isHit()) {
    echo $cachedItem->get(); // Outputs 'some_value'
}

// Switch to another adapter dynamically
$memcachedAdapter = new MemcachedCacheAdapter('127.0.0.1', 11211);
$cacheManager->setAdapter($memcachedAdapter);

Running Tests

You can run the test suite with PHPUnit:

composer test

Static analysis with PHPStan:

composer phpstan

Contributing

Feel free to submit issues or pull requests. For major changes, please open an issue to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-07