Download the PHP package stroker/cache without Composer

On this page you can find all versions of the php package stroker/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 cache

StrokerCache

Build Status Code Coverage Scrutinizer Quality Score SensioLabsInsight Total Downloads Latest Stable Version

This module provides a full page cache solution for Laminas.

Installation

Installation of StrokerCache uses composer. For composer documentation, please refer to getcomposer.org.

  1. cd my/project/directory
  2. create or modify the composer.json file within your ZF2 application file with following contents:

  3. install composer via curl -s https://getcomposer.org/installer | php (on windows, download https://getcomposer.org/installer and execute it with PHP). Then run php composer.phar install
  4. open my/project/directory/configs/application.config.php and add the following key to your modules:

Setup cache rules

Copy the file strokercache.local.php.dist to your config/autoload directory and rename to strokercache.local.php. Edit this file to reflect your needs.

The module provides several strategies to determine if a page should be cached.

Examples

Caching the home route:

Caching the foo/bar route, but only for a GET request and only when the param id equals 60

Change storage adapter

Storage adapter can be changed by configuration. Configuration structure is the same a StorageFactory consumes. See the Laminas reference guide. By default filesystem storage is used.

Example using APC:

TTL

You can set the TTL (Time to live) for the cache items by specifying the option on the storage adapter configuration. Not all Laminas storage adapters support TTL, which also is the reason why StrokerCache doesn't support per item TTL at the moment.

Clearing the cache

You can invalidate cache items using the provided console route. Alternatively you could pull strokercache_service from the servicelocator and call clearByTags directly from your application (i.e. from an event listener).

Run the following command from your project root: php public/index.php strokercache clear <tags>

Multiple tags can be seperated by a ,. Every page which is cached by StrokerCache is identified using the following tags:

To clear every page renderered by the someAction in MyNamespace\MyController do the following: php public/index.php strokercache clear controller_MyNamespace\MyController,param_action:some

To clear the route with alias player but only for the player with id 60. php public/index.php strokercache clear route_player,param_id_60

Custom id generators

You can create your own id generator by implementing the StrokerCache\IdGenerator\IdGeneratorInterface. Now register your generator to the PluginManager:

Custom strategies

You can create your own strategies by implementing the StrokerCache\Strategy\StrategyInterface. Now register your strategy to the pluginManager:

Next you need to enable the strategy

Disable FPC

You can disable the Caching solution all together by using the following configuration. This comes in handy on your development environment where you obviously don't want any caching to happen.

Events

The cache service triggers several events you can utilize to add some custom logic whenever saving/loading the cache happens. The events are listed as constants in the CacheEvent class:

Examples

Setting custom tags example

Log to file whenever a page is written to the cache storage

Say we want to disable caching for all requests on port 8080, we can simply listen to the SHOULDCACHE event and return false. Keep in mind you want to prevent other listeners from executing using stopPropagation(). If you don't do this other listeners will be executed and whenever one of them returns true the page will be cached. Also you need to attach the listener at a higher priority (1000 in this example) than the buildin strategies (they are registered at priority 100).

If you want to avoide caching because, for instance, the user is authenticated, do the same as above, but listen on LOAD instead of SHOULDCACHE:

Attention: Be aware, that you should probably disable storing for authenticated users as well:

Store directly to HTML files for max performance

This is still a bit expirimental. Please see this issue for some pointers how to get this working.


All versions of cache with dependencies

PHP Build Version
Package Version
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 stroker/cache contains the following files

Loading the files please wait ....