2017 © Pedro Peláez
 

library cachingmiddleware

The PSR-7 middleware for caching compatible to PSR-6.

image

clickalicious/cachingmiddleware

The PSR-7 middleware for caching compatible to PSR-6.

  • Monday, May 8, 2017
  • by clickalicious
  • Repository
  • 2 Watchers
  • 2 Stars
  • 1,092 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

, (*1)


Logo of Caching-Middleware, (*2)

The PSR-7 middleware for caching compatible to PSR-6., (*3)

Build Status Codacy grade Codacy coverage clickalicious open source
GitHub release license Issue Stats Dependency Status

Table of Contents

Features

  • Caching of almost any content produced in a PHP execution loop like PHP, HTML (...)
  • Stackable into PSR-7 stacks for easy integration
  • Compatible to all PSR-6 caching implementations and a lot of caching backends
  • High performance (developed using a profiler)
  • Lightweight and high-quality codebase (following PSR-1,2,4,7)
  • 100% PSR-7 middleware compatibility
  • 100% PSR-6 caching compatibility
  • Clean & well documented code
  • Unit-tested with a good coverage

Example

This is just a simple demonstration on how to get started using this middleware library in a very simple context. Put a Cache in queue and use a PSR-6 Cache (Filesystem as backend - but you could also use Redis, Memcached, MySQL or any other backend implemented a PSR-6 caching layer ...):, (*4)

/**
 * Fill queue for running "Caching Middleware"
 *
 * @param \Psr\Http\Message\ServerRequestInterface $request  Request (PSR) to process
 * @param \Psr\Http\Message\ResponseInterface      $response Response (PSR) to use
 * @param callable                                 $next     Next middleware in stack
 *
 * @return \Psr\Http\Message\ResponseInterface A PSR compatible response
 */
$queue[] = function (Request $request, Response $response, callable $next) {

    // Create cache item factory
    $cacheItemFactory = function ($key) {
        return new CacheItem($key);
    };

    // Create cache item key factory
    $cacheItemKeyFactory = function (Request $request) {
        static $key = null;
        if (null === $key) {
            $uri     = $request->getUri();
            $slugify = new Slugify();
            $key     = $slugify->slugify(trim($uri->getPath(), '/').($uri->getQuery() ? '?'.$uri->getQuery() : ''));
        }

        return $key;
    };

    // Get cache
    $cachingMiddleWare = new Clickalicious\Caching\Middleware\Cache(
        new CacheItemPool('Filesystem'),
        $cacheItemFactory,
        $cacheItemKeyFactory
    );

    return $cachingMiddleWare($request, $response, $next);
};

Requirements

  • PHP >= 5.6 (compatible up to version 7.2 as well as HHVM)

Philosophy

Caching Middleware is a PSR-7 compatible middleware based on PSR-6 compatible cache implementations. Caching Middleware isn't a unicorn - it's good but it maybe going to change with time. Try it, run it ... ♥ it ;), (*5)

Versioning

For a consistent versioning we decided to make use of Semantic Versioning 2.0.0 http://semver.org. Its easy to understand, very common and known from many other software projects., (*6)

Roadmap

  • [ ] Cache whole response instead just rendered HTML (Headers as well for example)
  • [ ] Implement flysystem as Driver for PSR-Cache

Throughput Graph, (*7)

Security Issues

If you encounter a (potential) security issue don't hesitate to get in contact with us opensource@clickalicious.de before releasing it to the public. So i get a chance to prepare and release an update before the issue is getting shared. Thank you!, (*8)

Participate & Share

... yeah. If you're a code monkey too - maybe we can build a force ;) If you would like to participate in either Code, Comments, Documentation, Wiki, Bug-Reports, Unit-Tests, Bug-Fixes, Feedback and/or Critic then please let us know as well! , (*9)

Sponsors

Thanks to our sponsors and supporters:, (*10)

JetBrains Navicat
Icons made by Prosymbols from www.flaticon.com is licensed by CC 3.0 BY

The Versions

06/04 2017

dev-benjamin-carl-patch-1

dev-benjamin-carl-patch-1 https://github.com/clickalicious/CachingMiddleware

CachingMiddleware - The PSR-6 Caching Middleware compatible to PSR-7 stacks.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr-7 stack cache caching psr-6 relay

16/04 2016

v1.1.1

1.1.1.0 https://github.com/clickalicious/CachingMiddleware

CachingMiddleware - The caching middleware compatible to PSR-7 stack implementations.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr-7 stack cache caching psr-6 relay

09/04 2016

v1.1.0

1.1.0.0 https://github.com/clickalicious/CachingMiddleware

CachingMiddleware - The caching middleware compatible to PSR-7 stack implementations.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr-7 stack cache caching psr-6 relay

19/12 2015

v1.0.1

1.0.1.0 https://www.clickalicious.de/

CachingMiddleware - The caching middleware compatible to PSR-7 stack implementations.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr-7 stack cache caching relay

25/10 2015

v1.0.0

1.0.0.0 https://www.clickalicious.de/

CachingMiddleware - The caching middleware compatible to PSR-7 stack implementations.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr-7 stack cache caching relay