Download the PHP package taitava/php-cachedcall without Composer

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

php-cachedcall

A simple PHP trait that makes it easy to cache class method call results within a single session.

Good for:

Not good for:

Installation

Use composer:

Then somewhere in your php application include the autoloader:

Usage

Say you have a class Page like this:

So we have two methods (plus a contructor) and we would like to cache both of them in order to avoid rerunning code if the methods get called multiple times with same parameters. Our code transforms to this:

getPageFromDB() is a static method that takes $id as a parameter. renderContent() method is non-static. When caching a non-static method, you should call $this->cached_call() method, where as in static methods you should call self::cached_static_call() method (or static::cached_static_call()). Remember to add the _static_ word in between when needed!

Both cached_call() and cached_static_call() have a similar set of parameters:

Limitations regarding $parameters

Please note that the $parameters can only contain:

The following are not accepted:

This limitation is in place because generating a cache key needs to be a fast process and it's hard to define a reliable cache key for i.e. a big array whose content can change between method calls. Also object support is quite limited because an object needs to have an id property. id() or getId() methods are not supported. All limitations can be improved later if better cache key generating ways come to mind.

To overcome some of the limitations, you can for example bypass an array parameter like this:

Note that we avoided passing $an_array to cached_call(), but we passed it to our closure function with the use ($an_array) statement! So we are able to use the array in it's original form.

Temporarily disabling the cache

If you need to quickly test your class without caching, you can alter the following properties:

Contributing

Ideas, bug reports and pull requests of fixes and new features are all welcome :).

Author

Jarkko Linnanvirta


All versions of php-cachedcall with dependencies

PHP Build Version
Package Version
Requires php Version ^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 taitava/php-cachedcall contains the following files

Loading the files please wait ....