ap-lib/routing-cache

Caching of an unchanging routing index is typically prepared on one computer and used on another.

Installs: 17

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/ap-lib/routing-cache

dev-main 2025-03-17 23:08 UTC

This package is auto-updated.

Last update: 2025-09-18 00:18:40 UTC


README

MIT License

Caching of an unchanging routing index is typically prepared on one computer and used on another.

Installation

composer require ap-lib/routing-cache

Features

  • Interface for saving and loading arrays what include links to classes to full related code
  • Implementation for saving and loading arrays to a PHP file

Requirements

  • PHP 8.3 or higher

Getting Started

// make routing
$routing = new Hashmap();

// setup index
$index = $routing->getIndexMaker();

$index->addEndpoint(Method::GET, "/", new Endpoint(
    [MainController::class, "handlerRoot"]
));

$index->addEndpoint(Method::GET, "/hello", new Endpoint(
    [MainController::class, "handlerHelloName"]
));

// Set up the cache object (in this case, it's just a filename)
$cache = new PhpFileRoutingCache("data.php");

// Store the index in the cache
$cache->set($index);

// Retrieve the array to init routing index from the cache
$retrieved_array = $cache->get();