PHPackages                             spiechu/json-disk-cache - 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. spiechu/json-disk-cache

Abandoned → [psr/simple-cache](/?search=psr%2Fsimple-cache)ArchivedLibrary[Caching](/categories/caching)

spiechu/json-disk-cache
=======================

Cache class intended to keep serialized data in JSON format files

0.2.1(8y ago)1030MITPHPPHP &gt;=5.6

Since Jul 8Pushed 8y agoCompare

[ Source](https://github.com/spiechu/JSON-Disk-Cache)[ Packagist](https://packagist.org/packages/spiechu/json-disk-cache)[ Docs](https://github.com/spiechu/JSON-Disk-Cache)[ RSS](/packages/spiechu-json-disk-cache/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

JSON Disk Cache
===============

[](#json-disk-cache)

[![Build Status](https://camo.githubusercontent.com/4327ce5dbf8675f3ffbac3742fd66c8d78f234ce4f07590adbd6d29864baceee/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f737069656368752f4a534f4e2d4469736b2d43616368652e706e67)](http://travis-ci.org/spiechu/JSON-Disk-Cache)[![Code Coverage](https://camo.githubusercontent.com/fe67d376c06520601174291fccb2c7941611a000035ced1de6287395aca151e3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f737069656368752f4a534f4e2d4469736b2d43616368652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spiechu/JSON-Disk-Cache/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8c64702e887bb0a1a7d1f74f225007f08e7a63eede9d1b298bb27429cc97bf84/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f737069656368752f4a534f4e2d4469736b2d43616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spiechu/JSON-Disk-Cache/?branch=master)

Cache class intended to keep serialized data in JSON format files.

There is one cache directory per all domains. `hashtable.cache` keeps cache hashes of all domains. `domain.cache` keeps hashes with serialized data.

Features
--------

[](#features)

Class caches data on disk using JSON format. Uses typical methods `set()`, `get()`, `clear()`.

Caches are grouped in domains. Each domain is contained in one file. Hashtable with pairs: name and (optional) params are stashed in file.

What is diffrent is method `getSet` which accepts array with object, method name and optionable params to execute when cache is not present.

Additionally any set cache has its own valid time, which can be set globally or per `set()`.

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

[](#requirements)

You need at least PHP 5.4 since library uses shorthand array creation `[]` and `(new Object)->method()` construction. If You want to run unit tests, PHPUnit 3.6 is needed.

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

[](#installation)

Library needs to be registered for autoload. It uses standard SplClassLoader, for example:

```
