The next-generation caching layer for PHP

Overview

Relay

Installation

First, follow the installation instructions to set up the Relay extension for PHP.

Next, either try the Laravel, WordPress or Magento integrations.

Alternatively, grab the Composer package and run the benchmarks:

composer require cachewerk/relay

Benchmarks

The host and port may be set in phpbench.json.

composer run bench
# ./vendor/bin/phpbench run --report=redis

composer run bench:verbose
# ./vendor/bin/phpbench run --report=redis --progress=blinken

Known Issues

Comments
  • PHP startup warning when installing via Homebrew

    PHP startup warning when installing via Homebrew

    After installing via Homebrew I get a PHP startup warning:

    Warning: PHP Startup: Relay is using the default binary ID of '31415926-5358-9793-2384-626433832795' in Unknown on line 0
    

    This warning prevents Valet from being able to restart PHP-FPM.

    opened by johnbillion 6
  • Does Relay work with a LiteSpeed server

    Does Relay work with a LiteSpeed server

    You mention PHP-FPM in your documentation. Does this mean that Relay cannot be used with a LiteSpeed/OpenLiteSpeed server, which uses its own LSAPI extensions?

    For more context, you say the requirements are the following php extensions: json, igbinary, and msgpack. I have the lsphp versions of those.

    Thanks!

    opened by nickchomey 6
  • RELAY_ERR_TIMEOUT

    RELAY_ERR_TIMEOUT

    I just got a stream of errors in my WordPress debug.log. The page was loading fine however.

    [12-Aug-2022 05:51:15 UTC] Relay\Exception: Timeout (RELAY_ERR_TIMEOUT) in /home/xyz.com/public_html/wp-content/object-cache.php:523
    Stack trace:
    #0 /home/xyz.com/public_html/wp-content/object-cache.php(523): Relay\Relay->ping()
    #1 /home/xyz.com/public_html/wp-content/object-cache.php(220): WP_Object_Cache->__construct()
    #2 /home/xyz.com/public_html/wp-includes/load.php(729): wp_cache_init()
    #3 /home/xyz.com/public_html/wp-settings.php(131): wp_start_object_cache()
    #4 /home/xyz.com/public_html/wp-config.php(140): require_once('...')
    #5 /home/xyz.com/public_html/wp-load.php(50): require_once('...')
    #6 /home/xyz.com/public_html/wp-blog-header.php(13): require_once('...')
    #7 /home/xyz.com/public_html/index.php(17): require('...')
    #8 {main}
    [12-Aug-2022 05:51:18 UTC] Relay\Exception: Timeout (RELAY_ERR_TIMEOUT) in /home/xyz.com/public_html/wp-content/object-cache.php:523
    Stack trace:
    #0 /home/xyz.com/public_html/wp-content/object-cache.php(523): Relay\Relay->ping()
    #1 /home/xyz.com/public_html/wp-content/object-cache.php(220): WP_Object_Cache->__construct()
    #2 /home/xyz.com/public_html/wp-includes/load.php(729): wp_cache_init()
    #3 /home/xyz.com/public_html/wp-settings.php(131): wp_start_object_cache()
    #4 /home/xyz.com/public_html/wp-config.php(140): require_once('...')
    #5 /home/xyz.com/public_html/wp-load.php(50): require_once('...')
    #6 /home/xyz.com/public_html/wp-admin/admin-ajax.php(22): require_once('...')
    #7 {main}
    [12-Aug-2022 05:51:19 UTC] Relay\Exception: Timeout (RELAY_ERR_TIMEOUT) in /home/xyz.com/public_html/wp-content/object-cache.php:523
    Stack trace:
    #0 /home/xyz.com/public_html/wp-content/object-cache.php(523): Relay\Relay->ping()
    #1 /home/xyz.com/public_html/wp-content/object-cache.php(220): WP_Object_Cache->__construct()
    #2 /home/xyz.com/public_html/wp-includes/load.php(729): wp_cache_init()
    #3 /home/xyz.com/public_html/wp-settings.php(131): wp_start_object_cache()
    #4 /home/xyz.com/public_html/wp-config.php(140): require_once('...')
    #5 /home/xyz.com/public_html/wp-load.php(50): require_once('...')
    #6 /home/xyz.com/public_html/wp-cron.php(44): require_once('...')
    #7 {main}
    

    I rebooted my VPS (Ubuntu 20.04) and it stopped happening. Any idea what it could be from and what I could do in the future to fix it without a full reboot?

    opened by nickchomey 5
  • feat(RelayOpenTelemetry): add db.statement attribute

    feat(RelayOpenTelemetry): add db.statement attribute

    There probably should be a way to disable this attribute in case the value is too large, but I am not sure how the API should look like so I left it for a future PR.

    opened by vmihailenco 2
  • [Amazon Linux] undefined symbol: gai_error

    [Amazon Linux] undefined symbol: gai_error

    It seems that AL2 builds are broken as of v0.4.0:

    > php --ri relay
    
    PHP Warning:  PHP Startup: Unable to load dynamic library 'relay.so' (tried: /usr/lib64/php/modules/relay.so (/usr/lib64/php/modules/relay.so: undefined symbol: gai_error), /usr/lib64/php/modules/relay.so.so (/usr/lib64/php/modules/relay.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    
    Extension 'relay' not present.
    
    docker build --pull --tag relay-amazon2 --file amzn2.Dockerfile .
    docker run -it relay-amazon2 bash
    php --ri relay
    
    bug 
    opened by tillkruss 2
  • Support setups w/o master thread

    Support setups w/o master thread

    Depending on a FPM-master thread is leading to several issues.

    1. We need to disable OBJC_DISABLE_INITIALIZE_FORK_SAFETY on macOS, otherwise SIP will just kill PHP/Relay
    2. Relay won't work if FPM daemonize is enabled
    3. Avoid taking down PHP when an fatal error occurs in the master thread
    roadmap 
    opened by tillkruss 1
  • Use closure for PSR tracers

    Use closure for PSR tracers

    Sentinel, Cluster and similar need to execute constructors in a closure to trace them.

    https://github.com/cachewerk/relay/blob/main/src/Psr/Tracing/RelayNewRelic.php

    enhancement 
    opened by tillkruss 0
  • Relay\Relay::get(): open_basedir restriction in effect.

    Relay\Relay::get(): open_basedir restriction in effect.

    Hello team,

    I am using Relay with a Laravel project that has the following versions:

    Laravel 9.21
    Relay 0.4.6
    PHP 8.1
    

    I am using it in production within a Docker environment with the PHP8.1-Relay extension and the serversideup/php:php8.1-fpm-nginx-v1.5.0 image on fly.io.

    Sometimes in production, I get the following exception:

    Relay\Relay::get(): open_basedir restriction in effect. File(/.dockerenv) is not within the allowed path(s): (/var/www/html:/dev/stdout:/tmp)
    

    I do not know where it is coming from or how to fix it. Do you have any ideas?

    Best regards, and thank you for your work.

    bug 
    opened by MaximeGratens 2
  • [Feature] Universal installer script

    [Feature] Universal installer script

    This PR is for https://github.com/cachewerk/relay/issues/26

    Done

    • [x] The script must use sh and not bash for portability
    • [x] The script must accept arguments to run without interaction, see last step
    • [x] Each step needs validation checks: Was the command completed or not?
    • [x] Use one-liner to download and execute
    • [x] Check if we have builds for the system it's executed on
    • [x] Detect "ini dir" of php binary
    • [x] Detect "extension dir" of php binary
    • [x] Check for needed PHP extensions (json, msgpack, igbinary) using php -m
    • [x] Check system dependencies(zstd, lz4 and openssl)
    • [x] Download correct binary to mktemp
    • [x] Inject UUID
    • [x] Move relay.so and relay.ini to ext/ini dirs
    • [x] Verify installation was completed: php --ri relay and UUID matches
    • [x] Show confirmation message that Relay was installed
    • [x] Print instructions how to call script without user interaction for what they just chose

    Todo

    • [ ] Find all php binaries
    • [ ] Show user a list of found executables
    • [ ] Let the user pass the php binary path
    • [ ] support macOS
    opened by zaherg 0
  • Universal install script

    Universal install script

    Having an interactive and non-interactive install script would be useful.

    1. The script must use sh and not bash for portability
    2. The script must accept arguments to run without interaction, see last step
    3. Each step needs validation checks: Was the command completed or not?
    4. Use one-liner to download and execute a. curl -sL https://sentry.io/get-cli/ | sh
    5. Check if we have builds for the system it's executed on a. For manual reference see: https://relay.so/builds b. Check OS as well as architecture c. Abort if os/arch isn't supported and show system information blob, prompt user to open a PR on this repo
    6. Next, find all php binaries a. Loop over PATHs and find binaries that contain *php* in the name b. Test if binary is a php executable using --version?
    7. Show user a list of found executables a. Show path + version + if that version is supported (7.4 — 8.2) b. Let user pick a binary to install Relay to
    8. Detect "ini dir" of php binary
    9. Detect "extension dir" of php binary a. php -i | grep '^extension_dir'
    10. Check for needed PHP extensions (json, msgpack, igbinary) using php -m a. Abort if any of them are missing and prompt user to install the ones that are missing
    11. Check system dependencies a. zstd, lz4 and openssl b. These libs are named differently on each system, we'll need checks for: Debian-based, CentOS-based, macOS-based and AlpineLinux-based systems c. If not found prompt user to install the package and abort
    12. Download correct binary to mktemp
    13. Inject UUID
    14. Move relay.so and relay.ini to ext/ini dirs
    15. Verify installation was completed: php --ri relay and UUID matches
    16. Show confirmation message that Relay was installed
    17. Print instructions how to call script without user interaction for what they just chose
    documentation help wanted 
    opened by tillkruss 4
Releases(v0.5.1)
Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

laminas-cache Laminas\Cache provides a general cache system for PHP. The Laminas\Cache component is able to cache different patterns (class, object, o

Laminas Project 69 Jan 7, 2023
DataLoaderPhp is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching.

DataLoaderPHP is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching.

Webedia - Overblog 185 Nov 3, 2022
Simple Yet Powerful PHP Caching Class

The PHP high-performance object caching system ever. phpFastCache is a high-performance, distributed object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. phpFastCache dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful

Khoa Bui 28 Aug 19, 2022
Stash - A PHP Caching Library

Stash - A PHP Caching Library Stash makes it easy to speed up your code by caching the results of expensive functions or code. Certain actions, like d

Tedious Developments 943 Dec 15, 2022
A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache tagging and indexing.

Apix Cache, cache-tagging for PHP Apix Cache is a generic and thin cache wrapper with a PSR-6 interface to various caching backends and emphasising ca

Apix 111 Nov 26, 2022
Yii Caching Library - Redis Handler

Yii Caching Library - Redis Handler This package provides the Redis handler and implements PSR-16 cache. Requirements PHP 7.4 or higher. Installation

Yii Software 4 Oct 9, 2022
Query caching for Laravel

Query caching for Laravel

Dwight Watson 1k Dec 30, 2022
Caching extension for the Intervention Image Class

Intervention Image Cache extends the Intervention Image Class package to be capable of image caching functionality.

null 616 Dec 30, 2022
Stash makes it easy to speed up your code by caching the results of expensive functions or code

Stash - A PHP Caching Library Stash makes it easy to speed up your code by caching the results of expensive functions or code. Certain actions, like d

Tedious Developments 943 Dec 15, 2022
Symfony Bundle for the Stash Caching Library

TedivmStashBundle The TedivmStashBundle integrates the Stash caching library into Symfony, providing a powerful abstraction for a range of caching eng

Tedious Developments 86 Aug 9, 2022
:zap: Simple Cache Abstraction Layer for PHP

⚡ Simple Cache Class This is a simple Cache Abstraction Layer for PHP >= 7.0 that provides a simple interaction with your cache-server. You can define

Lars Moelleken 27 Dec 8, 2022
Simple cache abstraction layer implementing PSR-16

sabre/cache This repository is a simple abstraction layer for key-value caches. It implements PSR-16. If you need a super-simple way to support PSR-16

sabre.io 48 Sep 9, 2022
PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.

Donate/Support: Documentation: https://www.scrapbook.cash - API reference: https://docs.scrapbook.cash Table of contents Installation & usage Adapters

Matthias Mullie 295 Nov 28, 2022
A flexible and feature-complete Redis client for PHP.

Predis A flexible and feature-complete Redis client for PHP 7.2 and newer. ATTENTION: you are on the README file of an unstable branch of Predis speci

Predis 7.3k Jan 3, 2023
LRU Cache implementation in PHP

PHP LRU Cache implementation Intro WTF is a LRU Cache? LRU stands for Least Recently Used. It's a type of cache that usually has a fixed capacity and

Rogério Vicente 61 Jun 23, 2022
A PHP extension for Redis

PhpRedis The phpredis extension provides an API for communicating with the Redis key-value store. It is released under the PHP License, version 3.01.

null 9.6k Jan 6, 2023
Elephant - a highly performant PHP Cache Driver for Kirby 3

?? Kirby3 PHP Cache-Driver Elephant - a highly performant PHP Cache Driver for Kirby 3 Commerical Usage Support open source! This plugin is free but i

Bruno Meilick 11 Apr 6, 2022
PHP local cache

__ ____ _________ ______/ /_ ___ / __ \/ ___/ __ `/ ___/ __ \/ _ \ / /_/ / /__/ /_/ / /__/ / / / __/ / ._

Jayden Lie 48 Sep 9, 2022
A fast, lock-free, shared memory user data cache for PHP

Yac is a shared and lockless memory user data cache for PHP.

Xinchen Hui 815 Dec 18, 2022