Download the PHP package rikudou/memoize-bundle without Composer

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

Symfony service memoization bundle

This bundle provides memoization for your services - every time you call the same method with the same arguments a cached response will be returned instead of executing the method.

Installation

Requires php 8.1+.

composer require rikudou/memoize-bundle

Afterwards add this to your composer.json autoload PSR-4 section: "App\\Memoized\\": "memoized/"

Example on fresh Symfony project:

Usage

You can simply use the provided attributes.

Every memoized class needs to implement at least one interface that you use to typehint the given service. A proxy class is created for each service with #[Memoizable] attribute. This proxy class decorates your service so that every time you ask for your service the proxy gets injected instead.

For non-memoized methods the proxy class simply passes the arguments through to your service while for memoized methods it also creates a cache key based on the parameters and looks for the result into the cache.

The proxy classes are generated in a compiler pass, meaning the proxy creation doesn't add overhead once container has been dumped.

Examples:

Class with one memoized method

This class will simply have the add() method memoized while sub() will not be memoized.

Whole class memoized

Here both add() and sub() methods will be memoized.

Whole class memoized without one method

Here the whole class will be memoized except for sub() method due to the #[NoMemoize] attribute.

Custom memoization validity

Here the whole class will be memoized with the cache validity set to 30 seconds.

Configuration

Tip: Create the default configuration file by using this command: php bin/console config:dump rikudou_memoize > config/packages/rikudou_memoize.yaml

There are these configurations:

enabled

Simple boolean to enable or disable memoization.

default_memoize_seconds

This parameter sets the default lifetime of memoized cache in seconds. Defaults to -1 which means until end of process (end of request in standard php-fpm or apache2 configurations).

Note that when the default value of -1 is used the cache_service configuration is ignored.

cache_service

This parameter controls which cache service is used for memoization. Defaults to cache.app meaning the default cache for your application.

If the default_memoize_seconds is set to -1 this config is ignored and a default in-memory implementation is used (service rikudou.memoize.internal_cache, class InMemoryCachePool).

key_specifier_service

This parameter allows you to specify a service that will alter the cache key. This is useful if your app relies on some kind of global state (like currently authenticated user etc.). It must implement the CacheKeySpecifier interface.

Default configuration

Generated by php bin/console config:dump rikudou_memoize

Example proxy class

The first code block is the original class, the second code block is the proxy.


All versions of memoize-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
symfony/framework-bundle Version ^5.4|^6.0|^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 rikudou/memoize-bundle contains the following files

Loading the files please wait ....