maslosoft/cache

易于使用、自动可配置、可扩展的缓存提供程序

2.0.0 2022-10-06 15:56 UTC

This package is auto-updated.

Last update: 2024-09-06 20:15:57 UTC


README

Cache Logo Maslosoft Cache

易于使用、自动可配置、可扩展的缓存提供程序

Latest Stable Version License

快速安装

composer require maslosoft/cache

文档

完整缓存文档

自配置缓存

此缓存库为流行的缓存系统提供一致的接口。它基于可配置的列表使用最佳缓存提供程序。

还提供无逻辑的缓存值获取,并回退到可调用的。

易于使用、自动可配置、可扩展的缓存提供程序

如果您只需要具有基本功能的现代缓存,这里就是。

它仅实现基本缓存操作

  • has - 检查缓存中是否有键
  • get - 通过键获取缓存值
  • set - 将值设置到缓存
  • remove - 删除缓存值
  • clear - 清除整个缓存

要求

  • PHP 5.6+
  • composer

设置

使用composer安装扩展

composer require maslosoft/cache:"*"

设置缓存。在调用init之后,任何进一步的实例都将配置如下$cache

use Maslosoft\Cache\Cache;

$cache = new Cache();
// Setup something here...
$cache->timeout = 1244;
$cache->init();

基本用法

<?php

use Maslosoft\Cache\Cache;

$cache = new Cache();

// Init configuration, now it is available anywhere
// By default it will try some cache providers and select best available.
$cache->init();

$key = 1;

if(!$cache->has($key))
{
	$cache->set($key, 'Some value');
}

echo $cache->get($key);

就是这样!

资源