Download the PHP package spiechu/json-disk-cache without Composer

On this page you can find all versions of the php package spiechu/json-disk-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-disk-cache

JSON Disk Cache

Build Status Code Coverage Scrutinizer Code Quality

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

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

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

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

Usage

At creation of JSONDiskCache object You can set cache directory in first param, otherwise jsoncache in JSONDiskCache.php directory will be set. Second param is default domain. Then You can set default cache valid time. Example below:

There are a few ways to set cache entry:

Now You can retrieve value from cache, notice that null value is treated as no cache at all:

You can also clear cache, true means cache was found and deleted:

Suppose You have $db object that retrieves data from database with $db->fetchData(1) method. When valid cache for pair array('dataName', 1) is found then cache is used, otherwise $db->fetchData(1):

To save cache to a file just do nothing. Just before object is being destroyed, its destructor will save cache to cache files. To force file write You can do:

Before cache is written to file, some maintenance is being performed automatically when cache entries numbers are above threshold. You can always do a function call:


All versions of json-disk-cache with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spiechu/json-disk-cache contains the following files

Loading the files please wait ....