juanchosl/simplecache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

juanchosl/simplecache

最新稳定版本:1.0.6

Composer 安装命令:

composer require juanchosl/simplecache

包简介

A small collection of read/write for multiples cache systems using PSR-16

README 文档

README

Description

A small collection of read/write functions for multiples cache systems

Install

composer require juanchosl/simplecache

Performance

From faster to slower

  • Process: It's only valid for current request execution
  • Session: Only valid for a current user session
  • Memcached: If Memcached service is available and Memcached library is installed
  • Redis: If Redis service is available and Redis library is installed
  • Memcache: If Memcached service is available and Memcache library is installed
  • File: The most compatible system, file into filesystem, but slower

How use it

Use directly one of the available libs

For create a cache instance

use JuanchoSL\SimpleCache\Repositories\ProcessCache;

$cache = new ProcessCache($_ENV['CACHE_ENVIRONMENT']);
//The max time to expire is 30 days if you do not set a time
$cache->setMaxTtl(3600 * 24);

For write a cache index

Set into $cache_key the $value, valid for $ttl seconds or default TTL if you don not pass a value

$result = $cache->set(string $cache_key, mixed $value, int $ttl = 0);

For read a cache index

Read from cache the contents of $cache_key and return his value or $default if it not exists or it is not valid

$cache_value = $cache->get(string $cache_key, $default = null);

For delete a cache index

Delete from cache the value with $cache_key

$result = $cache->delete(string $cache_key);

For write multiple cache indexes

Set into $cache_key the $values, an iterable containing a list of $cache_key => $value pairs, valid for $ttl seconds or default TTL if you don not pass a value

$result = $cache->setMultiple(iterable $values, \DateInterval|int $ttl = 0);

For read multiple cache indexes

Read from cache the contents of $cache_keys and return a list of $key => $value pairs. Missed keys has the $default value

$cache_value = $cache->getMultiple(iterable $cache_keys, $default = null);

For delete a cache index

Delete from cache the values from the $cache_keys list

$result = $cache->deleteMultiple(iterable $cache_keys);

For replace a cache index

Replace into cache the value with $cache_key with the $new_value without change his expiration time

$result = $cache->replace(string $cache_key, mixed $new_value);

For change the time to live of cache index

Change the expiration time of $cache_key with the new one passed as $new_ttl

$result = $cache->touch(string $cache_key, \DateInterval|int $new_ttl);

For increment a cache index numeric value

Increments the value into $cache_key adding $numeric_increment to his value. If not exists it is created.

$result = $cache->increment(string $cache_key, int|float $numeric_increment, \DateInterval|int $ttl_if_not_exists = $max_ttl);

For decrement a cache index numeric value

Decrements the value into $cache_key subtracting $numeric_decrement to his value. If not exists it is created.

$result = $cache->decrement(string $cache_key, int|float $numeric_decrement, \DateInterval|int $ttl_if_not_exists = $max_ttl);

For check if the cache contains a $cache_key

Check if key exists, is not recommended, because can be return true and just another script can remove it

$result = $cache->has(string $cache_key);

For clear all cache indexes

Remove all data from cache

$result = $cache->clear();

Use the provided adapter for use with compatibility with PSR-16 Simple-Cache

Create a cache instance

After create a Cache Instance, you can use it with the provided PsrSimpleCacheAdapter in order to work conform the PSR-16 https://www.php-fig.org/psr/psr-16/

use JuanchoSL\SimpleCache\Repositories\ProcessCache;
use JuanchoSL\SimpleCache\Adapters\PsrSimpleCacheAdapter;

$lib = new ProcessCache($_ENV['CACHE_ENVIRONMENT']);
$cache = new PsrSimpleCacheAdapter($lib);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固