2017 © Pedro Peláez
 

library php-cache

A psr/simple-cache implementation. PHP 7+

image

chillerlan/php-cache

A psr/simple-cache implementation. PHP 7+

  • Tuesday, January 23, 2018
  • by codemasher
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,857 Installations
  • PHP
  • 23 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 101 % Grown

The README.md

chillerlan/php-cache

A psr/simple-cache implementation for PHP 8.1+., (*1)

PHP Version Support ![version][packagist-badge] license ![Coverage][coverage-badge] ![Codacy][codacy-badge] ![Packagist downloads][downloads-badge]br/ Continuous Integration, (*2)

Features:

Requirements

Documentation

Installation using composer

You can simply clone the repo and run composer install in the root directory. In case you want to include it elsewhere, just add the following to your composer.json:, (*3)

(note: replace dev-main with a version constraint, e.g. ^4.1 - see releases for valid versions), (*4)

{
    "require": {
        "php": "^8.1",
        "chillerlan/php-cache": "dev-main"
    }
}

Installation via terminal: composer require chillerlan/php-cache, (*5)

Profit!, (*6)

Usage

Just invoke a cache instance with the desired CacheInterface like so:, (*7)

// Redis
$redis = new Redis;
$redis->pconnect('127.0.0.1', 6379);

$cache = new RedisCache($redis);

// Memcached
$memcached = new Memcached('myCacheInstance');
$memcached->addServer('localhost', 11211);

$cache = new MemcachedCache($memcached);

// APCU
$cache = new APCUCache;

// File
$cache = new FileCache(new CacheOptions(['cacheFilestorage' => __DIR__.'/../.cache']));

// Session
$cache = new SessionCache(new CacheOptions(['cacheSessionkey' => '_my_session_cache']));

// Memory
$cache = new MemoryCache;

Methods

See: Psr\SimpleCache\CacheInterface, (*8)

$cache->get(string $key, $default = null); // -> mixed
$cache->set(string $key, $value, int $ttl = null):bool
$cache->delete(string $key):bool
$cache->has(string $key):bool
$cache->clear():bool
$cache->getMultiple(array $keys, $default = null):array // -> mixed[]
$cache->setMultiple(array $values, int $ttl = null):bool
$cache->deleteMultiple(array $keys):bool

Disclaimer!

I don't take responsibility for molten memory modules, bloated hard disks, self-induced DoS, broken screens etc. Use at your own risk! :see_no_evil:, (*9)

The Versions

23/01 2018

dev-master

9999999-dev https://github.com/chillerlan/php-cache

A psr/simple-cache implementation. PHP 7+

  Sources   Download

MIT

The Requires

 

The Development Requires

cache php7 psr-16

23/01 2018

1.0.2

1.0.2.0 https://github.com/chillerlan/php-cache

A psr/simple-cache implementation. PHP 7+

  Sources   Download

MIT

The Requires

 

The Development Requires

cache php7 psr-16

27/05 2017

1.0.1

1.0.1.0 https://github.com/codemasher/php-cache

A psr/simple-cache implementation. PHP 7+

  Sources   Download

MIT

The Requires

 

The Development Requires

27/05 2017

1.0.0

1.0.0.0 https://github.com/codemasher/php-cache

A psr/simple-cache implementation. PHP 7+

  Sources   Download

MIT

The Requires

 

The Development Requires