Download the PHP package shieldon/simple-cache without Composer

On this page you can find all versions of the php package shieldon/simple-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-cache

PSR-16 Simple Cache

GitHub Action Travis CI Scrutinizer CI Code Coverage Code Quality
build Build Status Build Status codecov Scrutinizer Code Quality

Caching, a common performance-boosting technique, is a staple feature in many frameworks and libraries. This interoperability allows libraries to utilize existing caching implementations rather than creating their own. PSR-6 has addressed this issue, but its formal and verbose nature complicates simple use cases. PSR-16 is a simpler approach seeks to create a streamlined standard interface for common situations, ensuring compatibility with PSR-6 in a straightforward manner.

Showcase

Simple Cache is utilized in Cache Master, a WordPress Cache Plugin, and it performs excellently. Check it out if you're running WordPress sites; it won't let you down.

Built-in drivers:

The required parameters are marked by an asterisk (*)

Driver name ($driver) PHP modules ($config)
File file - *storage
Redis redis redis host, port, user, pass, unix_socket
MongoDB mongo mongodb host, port, user, pass, dbname, collection, unix_socket
MySQL mysql pdo_mysql host, port, *user, *pass, *dbname, table, charset
SQLite sqlite pdo_sqlite *storage
APC apc apc -
APCu apcu apcu -
Memcache memcache memcache host, port, unix_socket
LibMemcached memcached memcached host, port, unix_socket
WinCache wincache wincache -

Note:

The following command displays a list of installed PHP modules.

Before using, make sure the required PHP modules are installed on your system.


Table of Contents


Install

Usage

Cache

Class Cache is an adapter that not only allows the implemented instance of Psr\SimpleCache\CacheInterface, but also has built-in drivers already.

__construct($driver = '', $config = [])

Create a cache handler using the file driver.

Example:

$driver

(string|CacheInterface)

The class name of a built-in driver, or a PSR-16 driver that implements Psr\SimpleCache\CacheInterface.

$config

(array)

An array of parameters will be passed to a built-in driver.

Example:

Redis

File

Mysql

Sqlite

Mongo

Memcache, Memcached


API

Those API methods are defined on Psr\SimpleCache\CacheInterface. Please check out the PSR-16 document to get the detailed explanation.

set

Note that $ttl accepts null,int,DateInterval. The null means that the key never expires until deleted.

Example:

get

Example:

has

Example:

delete

Example:

setMultiple

Note that $ttl accepts null,int,DateInterval. The null means that the key never expires until deleted.

Example:

getMultiple

Example:

deleteMultiple

Example:

clear

Example:

clearExpiredItems Non-PSR-16

This method returns a list of deleted cache keys.

Note: Redis and Memcache, Memcached drivers will always return an empty array. See Garbage Collection section below.

Example:


Build Data Schema

The data schema needs to be built for the initial use of MySQL and SQLite drivers.

This API can be utilized for this purpose.

Or build it manually.

MySQL

SQLite


Garbage Collection

For built-in drivers, enabling garbage collection will automatically clear expired cache from your system.

Use the following parameters:

This implies a 1% probability of executing garbage collection. Avoid setting it to 100% as it will unnecessarily fetch and check all keys one by one.

Example:

You can just use the gc_enable to enable garbage collection.

Note

For the Redis, Memcache, and Memcached drivers, this method isn't necessary as expired items are automatically cleared.


Contributing

Thank you for your interest in contributing to our project! We welcome contributions from everyone. Before getting started, please take a moment to review the guidelines below:

Guidelines

Code Testing

We utilize a Docker image that includes various dependencies for our code testing. The image is based on /tests/Fixture/docker/Dockerfile and is preconfigured with the following components:

Follow the steps below to run the tests:


Author

The Origin of this Library

This PHP library was created for the 12th Ironman Game competition, hosted by ITHelp, a Taiwanese IT community. My chosen topic was "Road to PHP Master - The Best Practice in Open Source Code", composed in traditional Chinese. You can read it here if you're interested.

License

MIT


All versions of simple-cache with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
psr/simple-cache Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shieldon/simple-cache contains the following files

Loading the files please wait ....