PHPackages                             antevenio/memoize - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. antevenio/memoize

ActiveLibrary

antevenio/memoize
=================

In memory function memoizing, can be capped by total memory consumption and per function ttl.

0.0.16(6y ago)14.0kMITPHP

Since Sep 2Pushed 6y ago4 watchersCompare

[ Source](https://github.com/Antevenio/memoize)[ Packagist](https://packagist.org/packages/antevenio/memoize)[ RSS](/packages/antevenio-memoize/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (17)Used By (0)

antevenio/memoize
=================

[](#anteveniomemoize)

[![Latest Stable Version](https://camo.githubusercontent.com/14cd6429d60cd15f87d7d4b27b03cd4eec7788ac6bd1134b10f33dbbbf6ad357/68747470733a2f2f706f7365722e707567782e6f72672f616e746576656e696f2f6d656d6f697a652f762f737461626c65)](https://packagist.org/packages/antevenio/memoize)[![Total Downloads](https://camo.githubusercontent.com/ff8eec063e216d538bddbde8b47cad8c0a199d99668267be5edb4eefd63a1121/68747470733a2f2f706f7365722e707567782e6f72672f616e746576656e696f2f6d656d6f697a652f646f776e6c6f616473)](https://packagist.org/packages/antevenio/memoize)[![License](https://camo.githubusercontent.com/d5c9f740fb3f1317ebf7e2596c9be2b0349ee77e84318ba4e4ee508070b07e2f/68747470733a2f2f706f7365722e707567782e6f72672f616e746576656e696f2f6d656d6f697a652f6c6963656e7365)](https://packagist.org/packages/antevenio/memoize)[![Travis build](https://camo.githubusercontent.com/bb29f882eb6250cebe6cd2f5b9953a295252f6e55547519525cb069914fe9910/68747470733a2f2f6170692e7472617669732d63692e6f72672f416e746576656e696f2f6d656d6f697a652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Antevenio/memoize)[![Coverage Status](https://camo.githubusercontent.com/7c9b5d3a139cb1b08a046458e0d38f30da588433a95a5a7c65b296ea82c0a8a9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f416e746576656e696f2f6d656d6f697a652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Antevenio/memoize?branch=master)[![Maintainability](https://camo.githubusercontent.com/d7dad89b7a7a9140a84acfc66ded4647378884b2437bbdde69a23710bf2188af/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f64316539363237643031373934303261336437312f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/Antevenio/memoize/maintainability)

Yet another in memory function memoizing library.

Features
--------

[](#features)

- Can specify a maximum number of items for the cache to hold.
- Can place a TTL (time to live) per callable. (meaning that memoize will be returning the callable cached results until the TTL expires, in which case it will call the function again and generate a new cached result)
- Can override the default callable argument cache indexing with a custom one. (you can reuse a cached callable even passing different arguments if you want to do so)
- Caches thrown exceptions.

Behaviour
---------

[](#behaviour)

- When reaching the maximum number of items in cache, it will evict the oldest (first cached) callable first.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3

Installation
------------

[](#installation)

```
composer require antevenio/memoize
```

Usage
-----

[](#usage)

### Common code

[](#common-code)

```
