Download the PHP package exteon/identity-cache without Composer

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

IdentityCache

IdentityCache is a drop-in array replacement object cache designed to work with ORM and Identity Map patterns, providing Weakref-based unique identity-to-object resolution and smart caching of unused objects based on objects popularity

Abstract

The Identity Map pattern is very common in ORM implementations. It consists of an intermediate cache between the persistence and application layer, which is able to retrieve object instances by an unique object id. It must satisfy two requirements:

Many implementations use a PHP native array to store an identity => instance map; however this has the disadvantage of storing instances indefinitely, ultimately filling up memory even though the references are not still in use.

Implementation

The IdentityCache implements Weakref-based caching to satisfy the requirements and a popularity-based garbage collection algorithm to keep the size of the cached unused instances into configurable limits.

The IdentityCache and IdentityMap are designed as drop-in replacements for a native PHP array. The IdentityMap does not provide caching functionality; as soon as an object is not used anymore (its refcount drops to 0), the object is freed.

Requirements

Usage

Installing with composer

IdentityMap

IdentityCache

Configuration

An associative array can be passed to the constructor of \Exteon\IdentityCache\WeakReference\IdentityCache. Example usage, default and possible values are shown below. If a configuration option is not passed to the constructor, its default value will be used:

Popularity-based caching

When the purgeStrategy config option is popularity, a popularity index will be kept for the cached objects. An object's popularity increases by 1 whenever it is accessed from the cache.

In order to not keep forever objects that were once very popular but have not been used in a long time, an object's popularity also decays exponentially every time another object is accessed from the cache.

The value of the decay parameter can be specified by the popularityDecay config option. This is a very sensitive float value that can be computed using the getPopularityDecay() method, as such:

The meaning of the parameters above, shown with default values, is: If an object has at the present moment a popularity of initialPopularity (1000), then other objects are accessed from the cache a number of rounds (10000) times, the popularity of the initial object will drop to targetPopularity (2). By tweaking the value of popularityDecay, you can balance between keeping in the cache more of formerly popular objects or more of recent objects.

Acquiring objects

Mapped objects can be explicitly 'acquired', meaning the map/cache will hold them indefinitely even if they are no longer in use (they won't be purged). This is needed for 'dirty' objects that have been mutated and will need to be persisted later in a write-behind strategy scenario.

Example:

Invoking the garbage collector explicitly

The garbage collector is normally invoked every time an identity is added to the cache; it will then check if the trigger condition is satisfied and if so it will proceed to purge excess objects from the cache. The gc can be also invoked manually by calling the gc() method on IdentityCache.

Native PHP array replacements

If the Weakref extension is not available, or for testing purposes, or for an emergency in case the Weakref / WeakReference implementation is failing, we provide regular array-based replacements for the Weakref IdentityMap and IdentityCache:

\Exteon\IdentityCache\NativeArray\IdentityMap
\Exteon\IdentityCache\NativeArray\IdentityCache

These implement the same interfaces as their WeakRef / WeakReference counterparts, so they can be dropped in their place, but they will not implement any reference releasing functionality: objects added will remain in the IdentityMap or IdentityCache until explicitly unset().


All versions of identity-cache with dependencies

PHP Build Version
Package Version
Requires exteon/memory-helper Version ^1.0.1
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 exteon/identity-cache contains the following files

Loading the files please wait ....