PHPackages                             malenki/apc - 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. [Caching](/categories/caching)
4. /
5. malenki/apc

ActiveLibrary[Caching](/categories/caching)

malenki/apc
===========

Simple wrapper for some APC features.

56PHP

Since Apr 26Pushed 12y ago1 watchersCompare

[ Source](https://github.com/malenkiki/apc)[ Packagist](https://packagist.org/packages/malenki/apc)[ RSS](/packages/malenki-apc/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Apc
===

[](#apc)

Small wrapper of some apc features.

Install
-------

[](#install)

You can clone this repository or use **composer**, because [APC is available on Packagist](https://packagist.org/packages/malenki/apc)!

```
{
    "require": {
        "malenki/apc": "dev-master",
    }
}
```

Instanciate
-----------

[](#instanciate)

While you instanciate an object of this class, you must give at least one argument to set the key name:

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected'); // TTL = 0 by default here
```

You can give second argument, an positive integer, for the time to live duration in seconds:

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 60); // Given TTL is one minute
```

Setting value
-------------

[](#setting-value)

Very easy, you have the choice by using `set()` method or the magick setter `value`:

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
$apc->set('foo');
//or
$apc->value = 'foo';
```

Getting value
-------------

[](#getting-value)

As you have seen into previous case, you can use for getting value two ways: `get()` method or magic getter `value`.

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
var_dump($apc->get());
//or
var_dump($apc->value);
```

You may print content into string context too:

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
$apc->value = 'foo';
echo $apc; // will print "foo"
```

If the value is not a scalar, `print_r()` function is used.

Deleting value
--------------

[](#deleting-value)

You can force removing value from APC cache using `delete()` method or magic `unset()`:

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
$apc->set('foo');
$apc->delete();
// or
unset($apc->value);
```

Testing value
-------------

[](#testing-value)

You can test if a value exists before doing something with it. You have to call `exists()` method or magic `isset()`:

```
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);

// using method
if(!$apc->exists())
{
    $apc->value = 'foo';
}

// or magic isset()
if(!isset($apc->value))
{
    $apc->value = 'foo';
}
```

Cleaning the cache
------------------

[](#cleaning-the-cache)

You can clean all or just some part like `user` or `opcode`:

```
use \Malenki\Apc;
Apc::clean(); // clean all
// or
Apc::clean('user'); // clean user cache type
// or
Apc::clean('opcode'); // clean opcode cache type
```

###  Health Score

21

—

LowBetter than 17% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6af62130bd16d4e6bbaa5877829b6377386ef9fb6593592052dbb6eeb87c4a02?d=identicon)[malenki](/maintainers/malenki)

---

Top Contributors

[![malenkiki](https://avatars.githubusercontent.com/u/195776?v=4)](https://github.com/malenkiki "malenkiki (15 commits)")

### Embed Badge

![Health badge](/badges/malenki-apc/health.svg)

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

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)

PHPackages © 2026

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