Download the PHP package personnage/simple-cache without Composer

On this page you can find all versions of the php package personnage/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

SimpleCache: is a caching library for PHP

A PSR-16 cache implementation using unified API for various caching backends.

SimpleCache supports popular caching backends like Memcached and Redis out of the box.

PHP Version Build Status codecov Quality Score StyleCI


Installation

To install SimpleCache, simply:

The list below shows the supported storage:

Before using a Redis cache, you will need to either install the Predis package via Composer or install the PhpRedis PHP extension via PECL.


Using the Memcached driver requires the Memcached PECL package to be installed.

Cache Usage

Obtaining A Cache Instance

Retrieving items from the cache

The get method is used to retrieve items from the cache. If the item does not exist in the cache, null will be returned. If you wish, you may pass a second argument to the get method specifying the default value you wish to be returned if the item doesn't exist:

You may even pass a Closure as the default value. The result of the Closure will be returned if the specified item does not exist in the cache. Passing a Closure allows you to defer the retrieval of default values:

Checking for item existence

The has method may be used to determine if an item exists in the cache:

Incrementing / Decrementing values

The increment and decrement methods may be used to adjust the value of integer items in the cache. Both of these methods accept an optional second argument indicating the amount by which to increment or decrement the item's value:

Retrieve & Store

Sometimes you may wish to retrieve an item from the cache, but also store a default value if the requested item doesn't exist. You may do this using the remember method:

If the item does not exist in the cache, the Closure passed to the remember method will be executed and its result will be placed in the cache.

Retrieve & Delete

If you need to retrieve an item from the cache and then delete the item, you may use the pull method:

Storing items in the cache

You may use the set method to store items in the cache:

Storing items forever

The forever method may be used to store an item in the cache permanently. Since these items will not expire, they must be manually removed from the cache using the delete method:

If you are using the Memcached backend, items that are stored "forever" may be removed when the cache reaches its size limit.

Store if not present

The add method will only add the item to the cache if it does not already exist in the cache store. The method will return true if the item is actually added to the cache. Otherwise, the method will return false:

Replace if already exist

The replace method will only replace the item to the cache if it already exist in the cache store. The method will return true if the item is actually added to the cache. Otherwise, the method will return false:

Set a new expiration on an item.

The method will return true on success. Otherwise, the method will return false:

Removing items from the cache

You may remove items from the cache using the delete method:

You may clear the entire cache using the clear method:

Warning: Flushing the cache does not respect the cache prefix and will remove all entries from the cache. Consider this carefully when clearing a cache which is shared by other applications.

Cache Registry

The Cache class lets you configure global stores that you can then statically access from anywhere. Using the Cache registry, you may access various cache stores via the store method.

Default store

Using Events

To execute code on every cache operation, you may listen for the events fired by the cache.

The following events are dispatched:

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

License

The MIT License (MIT). Please see License File for more information.

Acknowledgements

SimpleCache is heavily inspired by Illuminate Cache and Scrapbook


All versions of simple-cache with dependencies

PHP Build Version
Package Version
Requires php Version ^5.5|^7.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 personnage/simple-cache contains the following files

Loading the files please wait ....