Download the PHP package parshikovpavel/array-cache without Composer

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

The package for caching data in memory using a PHP array.

As cached data is only available in the current request the package should be used for mocking the original cache in tests.

The cache implementation is compatible with PSR-6/PSR-16. In addition, CounterInterface (excluded from PSR-16) is included in the library and used for implementation.

The table below shows the correspondence between the library classes and the implemented interfaces.

PSR Class Implements
PSR-6 CacheItemPool CacheItemPoolInterface
PSR-6 CacheItem CacheItemInterface
PSR-16 Cache CacheInterface
PSR-16 + excluded CounterInterface CountingCache CacheInterface + CounterInterface

Installation

The recommended method of installing is via Composer.

Run the following command from the project root:

Usage

A detailed description of the interfaces implemented in the library can be found in PSR-6 and PSR-16.

Here are some common usage patterns of the library for testing your application using PHPUnit.

PSR-6

According to PSR-6, the package provides \ppCache\CacheItemPool class (implementing the \PSR\Cache\CacheItemPoolInterface interface) and \ppCache\CacheItem class (implementing the \PSR\Cache\CacheItemInterface interface).

Cache fixture

Use \ppCache\CacheItemPool instance as a fixture. Put the creating of the cache fixture into the setUp() method.

Dependency injection

If your application based on the dependency inversion principle and the dependency injection technique, it's very easy to replace a real cache with a mock cache.

Consider the case of constructor injection. Let's assume Client class provide a parameter in a constructor to inject a cache instance.

Get value from cache

The most common cache use case is a getting value and computing in case of cache miss.

A cache client must first try to get value from cache by $key.

PSR-16

According to PSR-16, the package provides \ppCache\Cache class (implementing the \Psr\SimpleCache\CacheInterface interface).

Cache fixture

Use \ppCache\Cache instance as a fixture. Put the creating of the cache fixture into the setUp() method.

Dependency injection

Similarly, inject a cache instance into the client constructor:

Get value from cache

The algorithm is the same as the one for \ppCache\CacheItemPool but the implementation is a bit simpler.

PSR-16 + CounterInterface

The package provides the \ppCache\CountingCache class which implements both the \Psr\SimpleCache\CacheInterface (introduced PSR-16) and the CounterInterface (excluded from PSR-16). CounterInterface definition is taken from PGP-FIG repository and is in this package.

The \ppCache\CountingCache implementation decorates a \ppCache\Cache instance and supplements its implementation with atomic increment-decrement methods.

Cache fixture

Dependency injection

Value increment and decrement

Unit testing

There are unit tests in the ./tests directory. You can run all tests with the following command:


All versions of array-cache with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
psr/cache Version ^1.0
psr/simple-cache Version ^1.0
parshikovpavel/psr-cache-adapter Version *
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 parshikovpavel/array-cache contains the following files

Loading the files please wait ....