oat-sa/lib-health-check-cache

OAT Cache Health Check Library

1.1.0 2023-03-23 14:40 UTC

README

Latest Version License GPL2 Build Status Coverage Status Packagist Downloads

PSR-6 cache health checker for the Health checks PHP library

Table of contents

Installation

$ composer require oat-sa/lib-health-check-cache

Usage

This library provides a CacheChecker checker in charge to check if the provided cache pool is reachable.

<?php

declare(strict_types=1);

use OAT\Library\HealthCheck\HealthChecker;
use OAT\Library\HealthCheckCache\CacheChecker;
use Psr\Cache\CacheItemPoolInterface;

$healthChecker = new HealthChecker();

/** @var CacheItemPoolInterface $cache */
$cacheChecker = new CacheChecker($cache);

$results = $healthChecker
    ->registerChecker($cacheChecker)
    ->performChecks();

Note: The built-in UuidCacheKeyGenerator can accept a custom prefix. If not provided, a default prefix will be used.

Note: If you need a custom logic to generate the cache key, create your own key generator by implementing CacheKeyGeneratorInterface Make sure your generated key is unique enough.

Tests

To run tests:

$ vendor/bin/phpunit

Note: see phpunit.xml.dist for available test suites.