Download the PHP package axetools/cachingtrait without Composer

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

AxeTools/CachingTrait

This is a php class trait that will enable static caching on a class.

Source Code PHP Programming Language Read License Build Status

Disclaimer

In general this does not promote good design patters. This is not a good package to include when creating a new project. The power of this package is having the ability to drop it into heavy classes that are difficult to refactor.

This package can greatly reduce execution times for classes that are instantiated in multiple locations that are heavy to create or have multiple database calls on instantiation. Classes that contain data that is not expected to change in the lifetime of a request. Sometimes it is not possible to pass these classes as a dependency when refactoring and an intermediary solution is needed.

WARNING: When writing tests that involve caching classes, remember the static cache is not automatically reset between tests. Care should be taken to ensure clean class caches at the start and end of each test case.

This project uses Semantic Versioning.

Installation

The preferred method of installation is via Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

Usage

The CachingTrait can be used with any class and will expose several protected methods to be utilized by the class to access the static cache array.

Example

setCache()

The self::setCache() static method to store data in the internal cache array. There is no protection to stop array keys from being overwritten. If you need to ensure you are not overwriting data utilize the self::hasCache() check to see if there is already data being stored for that key before setting the keys data.

Description

Parameters

key
The string array that will be used to identify the data that is being stored in the cache
data
The data that will be stored in the cache

Return Value

This method has no return

hasCache()

The self::hasCache() static method is used to see if there is already a key value stored in the cache array. Since anything can be stored in the cache array for a given key, only the existence of the give key in the cache array is checked with no consideration to the data stored for the key.

Description

Parameters

key
The string array that will be used to check for the data that is being stored in the cache

Return Value

This will return true if the key is found in the cache array and false if not found.

getCache()

The self::getCache() static method is used to retrieve the data stored in the cache assigned to the key specified. If the key is not defined in the cache array a CachingTraitMissingKeyException will be thrown.

Description

Parameters

key
The string array that will be used return the data that is being stored in the cache for that key

Return Value

This will return the value stored in the cache for the key provided. If the key is not defined in the cache array a CachingTraitMissingKeyException will be thrown.

clearCache()

Description

Parameters

key
Optional string array that will be used to clear the data and the key that is stored in the cache. If omitted the entire cache array is cleared.

Return Value

If the key is not defined in the cache array a CachingTraitMissingKeyException will be thrown.


All versions of cachingtrait with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.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 axetools/cachingtrait contains the following files

Loading the files please wait ....