flatphp/cache

cache component

Maintainers

Details

github.com/flatphp/cache

Source

Issues

Installs: 63

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/flatphp/cache

v3.0.0 2022-02-02 07:16 UTC

This package is auto-updated.

Last update: 2025-09-29 02:05:54 UTC


README

Light cache component;

relate: https://github.com/flatphp/memstore

Install

composer require "flatphp/cache"

Init Config

use Flatphp\Memstore\Conn;
use Flatphp\Cache\Cache;

Conn::init(array(
    'memcache' => ['host' => '127.0.0.1', 'port' => 11211]
));

Cache::init(array(
    'expiration' => 3600, // the default expiration, 0 forever[default]
    'storage' => 'memcache',
));

// -------- OR --------------------

Cache::init(array(
    'expiration' => 3600, // the default expiration, 0 forever[default]
    'storage' => array(
        'driver' => 'redis',
	'host' => 'localhost',
	'port' => 6379
    )
));

Useage

use Flatphp\Cache\Cache;

Cache::set('test', 1, 60);
echo Cache::get('test');
Cache::delete('test');
Cache::flush();

Cache::increment('test', 2);
Cache::decrement('test', 2);

Cache::getData('test', function(){
    return 'hello';
});