Download the PHP package pollora/object-cache without Composer

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

Pollora Object Cache: a persistent Redis object cache for WordPress

Latest version Total downloads Harness

A persistent object cache for WordPress, built for Pollora, the Laravel framework for WordPress. It keeps what WordPress caches (options, posts, terms, queries) in Redis between requests, instead of rebuilding it from the database on every page.

Status: early release (0.2). The engine, the Redis store, the object-cache.php drop-in, the Artisan commands and the Laravel cache driver are in, and the test suite runs against a real Redis in CI. Installing the package changes nothing until you run php artisan pollora:object-cache:enable. It has not run in production yet, and the API may change before 1.0: pin the version.

What it is

WordPress ships an object cache that lives for one request. A persistent object cache replaces it with a shared store, so the next request, and the next worker, finds the work already done. WordPress loads it from a drop-in file, wp-content/object-cache.php.

This package implements the whole contract of WP_Object_Cache: add, get, set, replace, delete, incr, decr, their *_multiple forms, flush, flush_group, flush_runtime, global and non-persistent groups, and multisite. It follows WordPress's own behavior, down to a stored false being a hit and a number never going below zero.

How it is built

Layer Holds
Domain The CacheStore contract, key building, cache groups (with wc_cache_*-style wildcards), time-to-live policy. No WordPress, no Redis, no Laravel.
Application ObjectCache: every operation, over a persistent store and a request cache.
Infrastructure The stores (in memory, and Redis with phpredis), the value format, the connector and the clock; the WordPress facade and the drop-in; the drop-in, the settings, the commands (WP-CLI) and the manager that both front-ends call.

Three decisions worth knowing:

The Redis store

RedisCacheStore talks to Redis 4.0 or later with phpredis (6.x is the tested one; ext-redis is optional, see below). It opens its connection on the first command and gives up after one second by default, so a Redis that stops answering cannot hang a request.

Using it

The package needs PHP and phpredis, nothing else: it runs on a classic WordPress, on Bedrock, and inside a Pollora project, where the framework configures it (see below).

enable and disable are idempotent. They only touch a drop-in this package wrote: another object cache's object-cache.php is left alone, and enable --force replaces it. A drop-in from an older version is updated by running enable again. The drop-in carries the path of the site's vendor/autoload.php, so a WordPress that does not load Composer's autoloader itself can still find the package. The web server must be able to read that path: a package installed with wp package install pollora/object-cache:^0.3 (give the constraint, or WP-CLI installs the unreleased dev-main) lands in the home directory of the user who ran it, which a web request usually cannot open. The drop-in then stays inert, WordPress keeps its own cache, and the PHP error log says so; status shows the path and flags one in the home directory.

If phpredis is not loaded, or nothing configures the cache, the drop-in defines nothing and WordPress runs on its own in-memory cache, with no error. If Redis stops answering during a request, the request carries on from its request cache, stops asking Redis, and the failure goes to the PHP error log once.

Configuration

Define the settings you change as an array in wp-config.php, before wp-settings.php is loaded. Every key is optional; config/object-cache.php lists them with their defaults.

Key Default
redis.url, redis.host, redis.port, redis.path (socket) 127.0.0.1, 6379
redis.username, redis.password, redis.database none, none, 0
redis.connect_timeout, redis.read_timeout 1.0 seconds
redis.persistent false
prefix WP_CACHE_KEY_SALT, else derived from DB_NAME, DB_HOST and the table prefix
serializer php (or igbinary)
allowed_classes true: any class (or false, or a list)
max_ttl 0, no limit
global_groups, non_persistent_groups []; a name may end with *
prefetch.enabled, prefetch.max_keys, prefetch.ttl false, 300, 604800 seconds
prefetch.exclude_groups ['userlogins']; a name may end with *

Prefetch

A WordPress page reads a hundred keys or more, one call to Redis each. With the prefetch on (OBJECT_CACHE_PREFETCH=true), the pages of one kind remember what they read, and the next one loads those keys with a single call.

It is off by default: turn it on, measure the number of Redis commands per page (redis-cli INFO commandstats), and keep it if it falls. On a development site (WordPress 7, WooCommerce, a Blade theme), once the profiles were written, the commands per request went from about 230 to 100-130 on the home page, from 203 to 126 on the shop page, and from 168 to 52 on a product page. A WooCommerce cart (add twice, read again, a second visitor) and a checkout through the Store API gave the same results with the prefetch on as without it.

Planned

Installation

Installing it changes nothing until the drop-in is enabled:

Requires PHP 8.3+. ext-redis is needed to reach Redis with phpredis, and ext-igbinary to use the igbinary serializer; both are optional, and without ext-redis the object cache will fall back to WordPress's in-memory cache.

Development

The Redis tests need a Redis they may empty: they use database 15 (OBJECT_CACHE_TEST_REDIS_DB) of REDIS_HOST:REDIS_PORT (127.0.0.1:6379), refuse database 0, and are skipped when there is no Redis, except in CI, where they fail instead.

Documentation

The package in a Pollora project: Object Cache.

Contributing

Contributions are welcome: see the contributing guide. Report security issues privately, as described in the security policy.

License

Pollora Object Cache is open-source software licensed under the RuBee group


All versions of object-cache with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
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 pollora/object-cache contains the following files

Loading the files please wait ...