All Projects → inpsyde → WP-Stash

inpsyde / WP-Stash

Licence: MIT license
Bridge between WordPress and StashPHP, providing a PSR6-compliant caching system for WordPress

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to WP-Stash

Cachemanager
CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
Stars: ✭ 2,049 (+6509.68%)
Mutual labels:  memcached, cache
Caching
⏱ Caching library with easy-to-use API and many cache backends.
Stars: ✭ 234 (+654.84%)
Mutual labels:  memcached, cache
Ansible Role Redis
Ansible Role - Redis
Stars: ✭ 176 (+467.74%)
Mutual labels:  memcached, cache
Wp Spider Cache
Your friendly neighborhood caching solution for WordPress
Stars: ✭ 133 (+329.03%)
Mutual labels:  memcached, cache
Fragment Cache
WordPress plugin for partial and async caching.
Stars: ✭ 135 (+335.48%)
Mutual labels:  wordpress-plugin, cache
Sequelize Transparent Cache
Simple to use and universal cache layer for Sequelize
Stars: ✭ 137 (+341.94%)
Mutual labels:  memcached, cache
Simple Spring Memcached
A drop-in library to enable memcached caching in Spring beans via annotations
Stars: ✭ 185 (+496.77%)
Mutual labels:  memcached, cache
Easycaching
💥 EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Stars: ✭ 1,047 (+3277.42%)
Mutual labels:  memcached, cache
Wp Rocket
Performance optimization plugin for WordPress
Stars: ✭ 394 (+1170.97%)
Mutual labels:  wordpress-plugin, cache
WP-Performance
Speed optimization plugin for Wordpress
Stars: ✭ 22 (-29.03%)
Mutual labels:  wordpress-plugin, cache
Overlord
Overlord是哔哩哔哩基于Go语言编写的memcache和redis&cluster的代理及集群管理功能,致力于提供自动化高可用的缓存服务解决方案。
Stars: ✭ 1,884 (+5977.42%)
Mutual labels:  memcached, cache
Redis Cache
A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Credis, HHVM, replication and clustering.
Stars: ✭ 205 (+561.29%)
Mutual labels:  wordpress-plugin, cache
Node Cached
A simple caching library for node.js, inspired by the Play cache API
Stars: ✭ 85 (+174.19%)
Mutual labels:  memcached, cache
Cachego
Golang Cache component - Multiple drivers
Stars: ✭ 148 (+377.42%)
Mutual labels:  memcached, cache
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (+74.19%)
Mutual labels:  memcached, cache
Phpfastcache
A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
Stars: ✭ 2,171 (+6903.23%)
Mutual labels:  memcached, cache
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+22796.77%)
Mutual labels:  memcached, cache
Outputcache
Cache api responses using Redis, Memcached or any cache provider for NodeJS
Stars: ✭ 9 (-70.97%)
Mutual labels:  memcached, cache
tiny-cache
Cache WordPress post content, template part, translations and nav menu output in persistent object cache
Stars: ✭ 26 (-16.13%)
Mutual labels:  wordpress-plugin, cache
Nginx Helper
Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
Stars: ✭ 170 (+448.39%)
Mutual labels:  wordpress-plugin, cache

WP Stash

WP Stash is a bridge between StashPHP and WP's object caching drop-in support. It enables APCu, Redis, SQLite, Memcached and Filesystem caches, stampede protection and group invalidation.

After installing, it will copy an object-cache.php file to wp-content/ which will delegate all cache calls to its mu-plugin folder. From there, it will interface with StashPHP.

Installation

This plugin is a composer package that will be installed as a wordpress-muplugin. As such, there are a few things to note when attempting to install it. Usually, MU-Plugins are single PHP files, sometimes accompanied by a subfolder containing more code. Since WP-Stash assumes it's living in a subfolder, it contains a lot of other dev-related stuff in its root folder.

For WP to pick up WP-Stash as a MU-Plugin, you have to do one of the following:

Composer

As a first step, simply require the package via composer

composer require inpsyde/wp-stash

Since this package will get installed in a subfolder. WordPress will not automatically load it on its own. The following solutions exist:

WP Starter

If you are using the awesome WP Starter package, then everything will work automatically. It contains a MU-Loader which will take care of loading WP Stash. Note that you MUST NOT use WPStarter's drop in functionality to copy object-cache.php on build time! WPStash must place the drop in file on its own. If you want to trigger WP-Stash to create the drop in file just run a command like wp plugin list.

WP Must-Use Plugin Loader

WP Must-Use Plugin Loader is a standalone composer package that will take care of loading mu-plugins for you. Just require the package and follow the usage instructions from the link to set it up.

Without Composer

Direct upload

You can technically use WP-Stash by simply extracting all files into the wp-content/mu-plugins/ folder. However, this is pretty dirty and we strongly disencourage doing so. Instead, please look at the WordPress Codex on MU-Plugins to find solutions for loading mu-plugins from folders.

The easiest solution is to add a wp-content/mu-plugins/wp-stash.php file and put the following in it:

<?php

require __DIR__ . '/wp-stash/wp-stash.php';

Configuration

You can configure WP Stash globally in the configuration file of your WordPress instance. It is possible to set a Cache Driver and configuration values for it.

Please consult the the StashPHP documentation for information on Driver configuration

The following constants (or environment variables) can be used for configuring WP Stash:

WP_STASH_DRIVER - FQCN : The class name of the Stash driver you want to use. Will fall back to Ephemeral (pure memory cache without persistence) if unset or invalid. Available drivers are:

  • \Stash\Driver\Apc
  • \Stash\Driver\FileSystem
  • \Stash\Driver\Sqlite
  • \Stash\Driver\Memcache (not Memcached)
  • \Stash\Driver\Redis
  • \Stash\Driver\Ephermal
  • \Stash\Driver\Composite

WP_STASH_DRIVER_ARGS - string: Driver constructor args as a serialized array or JSON.

WP_STASH_IN_MEMORY_CACHE - bool : If enabled, keeps an in-memory version of the cache in sync. This enhances performance during a single request. Default true.

WP_STASH_PURGE_INTERVAL - integer : WP Stash runs scheduled maintenance actions on the configured cache driver every 12 hours by default. You can configure a different interval here. Default 3600*12.

WP_STASH_BYPASS - bool : Allows temporarily disabling WP-Stash and falling back to the core WP system.

Environment variables

If you work with composer based enviroments like WPStarter you might want to use environemnt variables right away. Here are some examples:

Caching with APC:

WP_STASH_DRIVER=\Stash\Driver\Apc
WP_STASH_DRIVER_ARGS='{"ttl":3600}'

Caching to filesystem in the /var/www/cache folder:

WP_STASH_DRIVER=\Stash\Driver\FileSystem
WP_STASH_DRIVER_ARGS='{"path":"\/var\/www\/cache","dirSplit":1}'

Caching to a memcached server at localhost:

WP_STASH_DRIVER=\Stash\Driver\Memcache
WP_STASH_DRIVER_ARGS='{"servers":["memcached","11211"]}'

Don't cache persistently at all (cache lifes only within the script lifetime):

WP_STASH_DRIVER=\Stash\Driver\Ephermal

wp-config.php

define( 'WP_STASH_DRIVER',  '\Stash\Driver\Apc' );
define( 'WP_STASH_DRIVER_ARGS', serialize( array('ttl' => 3600 ) ) );

wp-cli

WP Stash has the following cli commands:

wp stash flush : An improved version of wp cache flush. This command ensures that wp_cache_flush() is called by the web server, not the cli process (which might run as a different user, or with a different configuration). This ensures compatibility with all caching back-ends.

wp stash purge : Some drivers require that maintenance action be performed regularly. The FileSystem and SQLite drivers, as an example, need to remove old data as they can't do it automatically. While this is automatically performed via WP cron, you can trigger the process manually with this command.

Ensure your persistent cache works as expected

To test if your persistent cache works you can use WP-CLI. First, log in to your WordPress site with your user. Now run the following command in WP-CLI:

wp cache get {your-user-ID} users
(object) array(
   'ID' => '1',
   'user_login' => 'you',
   'user_pass' => '$P$BfWcDiF3YcFfnIMAGUmiYOuxD/6eaY0',
   'user_nicename' => 'you',
   'user_email' => '[email protected]',
   'user_url' => 'https://yourdomain.com',
   'user_registered' => '2018-02-09 21:44:34',
   'user_activation_key' => '',
   'user_status' => '0',
   'display_name' => 'Your Name',
   'spam' => '0',
   'deleted' => '0',
)

This has some limitations and might not work on some server setups depending on whether the webserver and your console user are the same.

In that case you could check if common transients are stored in the cache. First delete all transients just in case there are some left:

wp transient delete --network --all
Success: No transients found.
Warning: Transients are stored in an external object cache, and this command only deletes those stored in the database. You must flush the cache to delete all transients.

Now clear the cache

wp stash flush

Now check for updates (to fill the transient) and request the cache object:

wp core check-update
Success: WordPress is at the latest version.
wp cache get update_core site-transient
(object) array(
   'updates' => 
  array (
    0 => 
    (object) array(
       'response' => 'latest',
...

License and Copyright

Copyright (c) 2020 Inpsyde GmbH.

WP Stash code is licensed under MIT license.

The team at Inpsyde is engineering the Web since 2006.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].