Download the PHP package cyber-duck/cacheing-memoizer without Composer

On this page you can find all versions of the php package cyber-duck/cacheing-memoizer. 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 cacheing-memoizer

🚨 Discontinued 🚨

Please consider using the illuminate cache package.

Simple Cacheing Memoizer

Our Simple Cacheing Memoizer is a flexible memoizer that can also optionally be combined with a cache to automatically memoize results of calling functions.

We've implemented one example of the latter function using cyber-duck/laravel-cacheing-memoizer which adds it to Laravel for you, but it can also be used in other frameworks - it was originally written for a legacy site that is being upgraded from Codeigniter to Laravel gradually, and works fine in both.

Usage

Memoization

add

use CyberDuck\CacheingMemoizer\MemoizesResults

to your class.

This will give your class extra methods, the most important of which is memoize.

Memoize takes two or more arguments.

The first are the building blocks of the memoization key. The second is a function that will return the value to be memoized. The third and any subsequent arguments will be passed to the function when it is invoked.

Memoization is by default unique to the object, but it is also possible to use singletonMemoize which is exactly the same as memoize except it memoizes the value of the result in one sningleton

Important note: Because this is framework agnostic, the memoizer has to manage the singleton itself. So it may not be the 'same' singleton as your framework preservers. If this is important then over-write the singletonMemoize method.

There is also a globallyMemoize method. This essentially memoizes the result with that key for any object.

Cacheing

You may also use the memoization features with automated cacheing. This requires two steps:

  1. Setup the memoizer to use the cache by:

    1. call CyberDuck\CacheingMemoizer\CacheingMemoizer::setCacheRetrievalFunction with a callable which should accept one argument - the cache key - and return the result if there is a cache hit, null other wise.
    2. call CyberDuck\CacheingMemoizer\CacheingMemoizer::addShutdownFunction at least once with a callable which should accept two arguments - key, then value, which will write to the cache
    3. arrange for CyberDuck\CacheingMemoizer\CacheingMemoizer::shutdown to be called at the end of the request.

(if you are using Laravel, cyber-duck/laravel-cacheing-memoizer will do this for you)

  1. Use globallyMemoizeWithCache in the same way as globallyMemoize

Other methods

See source code. Documentation coming. forget and getMemoizeKey are the main ones, their import hopefully obvious.

Can I see a couple of examples of this in use please?

Certainly, here's a simple example of using it in one class to avoid the overhead of an expensive call:

Here's an example of how quickly we added memoization + cacheing to a function in 5+ year old legacy code, without having to rewrite anything fresh. The original function looked like:

With automated memoization + cacheing it now looks like:


All versions of cacheing-memoizer with dependencies

PHP Build Version
Package Version
No informations.
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 cyber-duck/cacheing-memoizer contains the following files

Loading the files please wait ....