PHPackages                             modulework/cachework - 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. modulework/cachework

ActiveModulework-module[Caching](/categories/caching)

modulework/cachework
====================

A simple way of caching information to disk

v1.0(13y ago)118Apache 2.0PHPPHP &gt;=5.3.0

Since Jun 7Pushed 10y ago1 watchersCompare

[ Source](https://github.com/MODULEWork/CACHEWork)[ Packagist](https://packagist.org/packages/modulework/cachework)[ RSS](/packages/modulework-cachework/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

CACHEWork
=========

[](#cachework)

A simple way of caching information to disk

Installation:
-------------

[](#installation)

- Place the cache.php file into your application folder
- Include it `include_once 'cache.php'; `
- and initate it: `Cache::init('cache/');`

Make sure that you enter the relative path to the cache directory from where the `init()` is called! The **MODULE** will do the work for you of determining the absolute path. This way you can can cache items from everywhere and don' t need to worry of pathes.

- Make sure that PHP can write into the cache folder!
- Make sure that you are **NOT** creating objects of this class!
- Cache some stuff
- Do **NOT** re-init the class.

HowTo
-----

[](#howto)

There are 5 methods available for you to interact with your cache.

- `put($key, $value, $serialize = true, $override = true)`
- `get($key, $value, $expire, $default = null)`
- `forget($key)`
- `remember($key, $value, $serialize = true, $override = true)`
- `clear($expire)`

Everywhere you find something like this `$var = true`, it' s an optional value. If you don' t pass any information for this variable it will set it to the default value. The default values are the most commonly used.

PUT
---

[](#put)

`put($key, $value, $serialize = true, $override = true)`

This method will store a value into the cache for a undefined time.

- `$key`: string: the unique key for this cache item. Used for retrieval.
- `$value`: mixed: The value you want to cache. Objects, arrays, closures are possible.
- `$serialize `: bool: `true` will serialize the value (not when the value is callable!
- `$override `: bool: `true` will override any existing cache items.

**Example usage:**

```
$variable = file_get_contents('http://google.com');
Cache::put('key', $variable);

```

This will store the result of the `file_get_contents()` into the cache. But you can even store closures (functions) into the cache like this:

```
Cache::put('get_google', function() {
     $localvar = file_get_contents('http://google.com');
     //complicated alogrithem
     return $result;
});

```

The `$result` will get stored into the cache.

GET
---

[](#get)

`get($key, $expire, $default = null)`

This method will retrieve a value from the cache, but only if it is **NOT** older then `$expire` seconds

- `$key`: string: the unique key for this cache item. Used in the `put()` method.
- `$expire`: int: The time in seconds the file could be old.
- `$default `: mixed: The value will get returned if no cache item exists or the cache item is too old.

**Example usage:**

```
$key = 'get_google';
$expire = 60 * 60 * 24; // 1 day
Cache::get('key', $expire);

```

This will return the result the closure (used in the previous example) as long as the `put()` was not before 1 day.

FORGET
------

[](#forget)

This will remove the cache item for the given key.

```
Cache::forget('get_google');

```

This will remove the file from the disk, forever (a very long time).

REMEMBER
--------

[](#remember)

This is the most used method from this class and combines `put()` and `get()`.
The syntax looks like that:

`Cache::remember($key, $value, $expire, $serialize = true, $override = true);`

As you can see it is using the same parameters as `get()` and `put()`.

An example:

```
 Cache::remember('get_google', function() {
    return file_get_contents('http://google.com');
 }, 60 * 60 * 24); //1 day

```

This will save the the contents of `http://google.com` into the cache and refreshes the the result every 24 hours (if you are visting the site every 1 hour :D). This is in most cases the most useful method, because you do not have two write your own refresh code.

CLEAR
-----

[](#clear)

This function will clear all cached items older than `$expire` seconds.
Cache::clear($expire);

Thats it! Simple and straight forward.

You can always have a look at the PHP doc for a brief explanation.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4772d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2886317?v=4)[Christian Gärtner](/maintainers/ChristianGaertner)[@ChristianGaertner](https://github.com/ChristianGaertner)

---

Top Contributors

[![ChristianGaertner](https://avatars.githubusercontent.com/u/2886317?v=4)](https://github.com/ChristianGaertner "ChristianGaertner (10 commits)")

### Embed Badge

![Health badge](/badges/modulework-cachework/health.svg)

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

###  Alternatives

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32136.0k](/packages/beryllium-cachebundle)

PHPackages © 2026

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