acdh-oeaw/arche-diss-cache

Response and resources cache for ARCHE dissemination services

Maintainers

Package info

github.com/acdh-oeaw/arche-diss-cache

pkg:composer/acdh-oeaw/arche-diss-cache

Transparency log

Statistics

Installs: 1 288

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

3.0.9 2026-07-17 15:37 UTC

README

Latest Stable Version Build Status Coverage Status License

Provides a framework for writing ARCHE Suite dissemination services.

Takes care of:

  • Caching dissemination service responses.
  • Fetching and caching repository resource metadata.
  • Fetching and caching repository resource binaries.
  • Checking aurhorization.
  • Support of web standards like honoring Cache-Control and Accepted-Encoding HTTP request headers, emitting Cache-Control HTTP header, etc.

Basic use

<?php
use Psr\Log\AbstractLogger;
use acdhOeaw\arche\lib\RepoResourceInterface;
use acdhOeaw\arche\lib\dissCache\Service;
use acdhOeaw\arche\lib\dissCache\ResponseCache;
use acdhOeaw\arche\lib\dissCache\ResponseCacheItem;


class MyClass {
    static public method cacheHandler(
        RepositoryResourceInterface $res, 
        array $serveRequestParam,
        CallbackContextInterface $contextObj,
        object $config
    ){
        ...whatever needed...
        return new ResponseCacheItem($responseBody, $responseStatusCode, $responseHttpHeaders);
    }
}

$service = new Service('path_to_config.yaml');
$service->setCallback(fn($res, $param, $contextObj) => MyClass::cacheHandler($res, $param, $contextObj, $service->getConfig()));
$resId    = ...obtainResourceIdentifierFromTheRequest...;
$param    = [...readRequestParametersFromTheRequest...];
$response = $service->serveRequest($resId, $param);
$response->send();

The sample YAML config file can be found in tests/config.yaml.

Getting access to the logger

$cache->getLog()

Getting acces to the repository resource binary content

$pathToFile = $cache->getFileCache()->getResourceBinaryPath($res);