PHPackages                             codedgr/memory - 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. [Database &amp; ORM](/categories/database)
4. /
5. codedgr/memory

ActiveLibrary[Database &amp; ORM](/categories/database)

codedgr/memory
==============

Store your data in ram, database, session and cookie.

1.0.1(7y ago)026MITPHPPHP &gt;=7.1.0

Since Jun 8Pushed 6y agoCompare

[ Source](https://github.com/codedgr/memory)[ Packagist](https://packagist.org/packages/codedgr/memory)[ Docs](https://github.com/codedgr/memory)[ RSS](/packages/codedgr-memory/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Memory
======

[](#memory)

This library helps you to store temporary data in your memory, database, cookie or session. Use it to cache data to improve the speed of your script.

Install
-------

[](#install)

Using Composer

```
"require": {
    "codedgr/memory": "~1.0"
}

```

Store data to memory, session, database or cookie
-------------------------------------------------

[](#store-data-to-memory-session-database-or-cookie)

Initialize the memory. Note that cookie does not need to initialized.

```
Ram::init();
Session::init();
Database::init($pdo);

```

Add data to the cache if the cache `$key` doesn't already exist. If it does exist, the data is not added and the function returns `false`.

```
Ram::add($key, $data, $expire);
Session::add($key, $data, $expire);
Database::add($key, $data, $expire);
Cookie::add($key, $data, $expire);

```

Add data to the cache. If the cache `$key` already exists, then it will be overwritten; if not then it will be created.

```
Ram::set($key, $data, $expire);
Session::set($key, $data, $expire);
Database::set($key, $data, $expire);
Cookie::set($key, $data, $expire);

```

Replaces the given cache if it exists, returns `false` otherwise.

```
Ram::replace($key, $expire, $group);
Session::replace($key, $expire, $group);
Database::replace($key, $expire, $group);
Cookie::replace($key, $expire, $group);

```

Get the value of the cached object, or `false` if the cache `$key` doesn't exist.

To disambiguate a cached `false` from a non-existing `$key`, you should do absolute testing of `$found`, which is passed by reference, against `false`: if `$found === false`, the key does not exist.

```
Ram::get($key, $expire, &$found = null);
Session::get($key, $expire, &$found = null);
Database::get($key, $expire, &$found = null);
Cookie::get($key, $expire, &$found = null);

```

Clears data from the cache for the given `$key`.

```
Ram::delete($key, $expire);
Session::delete($key, $expire);
Database::delete($key, $expire);
Cookie::delete($key, $expire);

```

Clears all cached data. Note that you can't flash the cookie memory.

```
Ram::flush();
Session::flush();
Database::flush();

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2898d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fabb412180db5250724ef8144d5fb430864b5398362f54397f2ad0bc72c0ec3?d=identicon)[codedgr](/maintainers/codedgr)

---

Top Contributors

[![keramaros](https://avatars.githubusercontent.com/u/39630991?v=4)](https://github.com/keramaros "keramaros (1 commits)")

---

Tags

databasecachememorycookie

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codedgr-memory/health.svg)

```
[![Health](https://phpackages.com/badges/codedgr-memory/health.svg)](https://phpackages.com/packages/codedgr-memory)
```

###  Alternatives

[fire015/flintstone

A key/value database store using flat files for PHP

285108.7k7](/packages/fire015-flintstone)[bvanhoekelen/performance

PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.

521774.3k4](/packages/bvanhoekelen-performance)[aplus/session

Aplus Framework Session Library

2141.6M3](/packages/aplus-session)[ytake/laravel-couchbase

Couchbase providers for Laravel

3051.9k](/packages/ytake-laravel-couchbase)[vectorial1024/laravel-cache-evict

Efficiently remove expired Laravel file/database cache data

5813.2k](/packages/vectorial1024-laravel-cache-evict)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
