Download the PHP package simplecomplex/cache without Composer
On this page you can find all versions of the php package simplecomplex/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simplecomplex/cache
More information about simplecomplex/cache
Files in simplecomplex/cache
Package cache
Short Description File-based PSR-16 Simple Cache implementation; cache management; CLI interface.
License MIT
Homepage https://github.com/simplecomplex/php-cache
Informations about the package cache
Cache
- Installation
- Requirements
Scope
Caching of complex variables, and variables which are expensive to generate.
Like configuration, localization and service responses.
Not page caching, no stampede protection.
Cache abstraction
**** decouples code using cache from the actual PSR-16 cache implementation.
Defines three cache class aliases:
- variable time-to-live (default ttl and set() arg ttl)
- fixed time-to-live (default ttl, set() arg ttl ignored)
- persistent (default ttl 'forever' and set() arg ttl ignored)
Plus three like the above which allow long keys; length 128 instead of the PSR-16 compliant 64.
How to use
Ask for an aliased type of cache instance - do not instantiate a particular cache class.
Extend , if you later want to switch from say file-based to database-based caching.
Dependency injection container ID: cache-broker
Recommendation: access (and thus instantiate) the cache broker via DI container ID 'cache-broker'.
See SimpleComplex Utils .
File-based caching
**** is a thorough and cautious PSR-16 Simple Cache implementation; file-based.
Coded defensively - key (and other argument) validation.
Addresses:
- default time-to-live; ignore set() arg ttl option; no time-to-live
- garbage collection
- clearing all items or expired items only
- exporting all items, to JSON
- building/replacing a cache store during production (using a 'candidate' store)
- CLI interface for clearing items, e.g. via cron
- concurrency issues (storage-wise only)
Cache management, replacement and backup
Defines two extensions to the PSR-16 CacheInterface, implemented by .
- is the cache store new or empty?
- setting default time-to-live; setting 'ignore' set() arg ttl
- clearing and exporting
- listing all cache stores
- backup/restore
- replacing a store, by building a 'candidate' and switching to that when it's complete
Example
CLI commands
Installation
Create a 'private' files directory alongside the document root dir
and make it writable for the webserver user (www-data or apache).
Like:
On first cache store instantiation, **** will create directory
If that directory structure isn't suitable, do either:
- supply (or constructor directly) with a 'path' argument
- extend and override it's class constant
Requirements
- PHP >=7.0
- 64-bit PHP
- PSR-16 Simple Cache
- SimpleComplex Utils
Suggestions
All versions of cache with dependencies
psr/simple-cache Version ^1.0 || dev-develop
simplecomplex/utils Version ^1.8 || ^2.0 || dev-develop