Download the PHP package ryanj93/php-tiny-cacher without Composer

On this page you can find all versions of the php package ryanj93/php-tiny-cacher. 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 php-tiny-cacher

PHP Tiny Cacher

PHP Tiny Cacher is a simple package that provides a simple API for data caching supporting multiple storage options, such as Redis, Memcached, SQLite and files, supporting basic operations, increments and TTL, allowing to store strings as well as other kind of variables that will be serialised into JSON or other formats, according to the storage strategy in use.

Installation

According with your needs, you may have to install some additional extensions: if you are going to use Redis, you need to install the required extension using the command pecl install redis, in a similar way to use Memcached, you need to install the required module using the command pecl install memcached (sometimes this extension is shipped with PHP), about SQLite3, it is usually shipped with PHP. Once the requirements are mets, you can install the module running this command:

`

Usage

First you need to set up a class instance according with the storage option that you are going to use, here you are some examples:

Basic setup

First you need to create an instance of the class, then you can set the general setting like the namespace for cache entries and the default TTL.

``

Using internal storage

You can save your data internally within the class instance or in a shared way:

``

Using Redis

``

For more information about the extension used with Redis check the official repository on GitHub.

Using Memcached

``

For more information about the extension used with Memcached check the official page on the PHP documentation.

Using SQLite3

``

For more information about the SQLite3 extension refer on the official documentation that can be found to the page on the PHP documentation.

Using files

``

Operations

Once you created the class instance and completed the connection with the storage service you can start adding items to the cache, here you are an example:

``

In a similar way you can retrieve the value of one or multiple keys, here an example:

``

You can check if a key exists as following:

``

Then you can remove a key in this way:

``

If you are working with numeric values you can use increments, note that currently this feature is not available when using files as storage option:

``

You can remove all stored elements using this method, alternatively you can remove all the elements stored under a given namespace:

``

If you switch to another storage strategy, you may want to close no more used connections, in this case you may want to run this method:

``

Considerations on TTL

TTL is supported in almost all storage options, anyway currently is not supported when using file as option. TTL is natively supported by Redis and Memcached, while is you are using another storage option you will need to use one of these technique in order to remove dead records, note that expired records will not be considered in data readings so this operation is only required whenever you need to free up some memory, here you are some usage example:

``

If you like this project and think that is useful don't be scared and feel free to contribute reporting bugs, issues or suggestions or if you feel generous, you can send a donation here.

Are you looking for the Node.js version? Give a look here.


All versions of php-tiny-cacher with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
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 ryanj93/php-tiny-cacher contains the following files

Loading the files please wait ....