maslosoft/cache

Easy to use, auto configurable, extensible cache provider

2.0.0 2022-10-06 15:56 UTC

This package is auto-updated.

Last update: 2024-10-06 20:30:23 UTC


README

Cache Logo Maslosoft Cache

Easy to use, auto configurable, extensible cache provider

Latest Stable Version License

Quick Install

composer require maslosoft/cache

Documentation

Full Cache Documentation

Self configuring cache

This cache library provides consistent interface for popular cache systems. It uses best cache provider available based on configurable list.

Also provides logic-less getting of cache value, with fallback to callable.

Easy to use, auto configurable, extensible cache provider

If you need some modern cache with just basic features here it is.

It implements only basic cache operations:

  • has - to check if has key in cache
  • get - to get cached value by key
  • set - to set value to cache
  • remove - to remove cached value
  • clear - to clear entira cache

Requirements

  • PHP 5.6+
  • composer

Setup

Use composer to install extension:

composer require maslosoft/cache:"*"

Setup cache. After calling init any further instance will be configured same as below $cache.

use Maslosoft\Cache\Cache;

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

Basic Usage

<?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);

And that's it!

Resources