marko/cache

Cache interfaces and infrastructure for Marko Framework

Maintainers

Package info

github.com/marko-php/marko-cache

Type:marko-module

pkg:composer/marko/cache

Statistics

Installs: 4

Dependents: 5

Suggesters: 1

Stars: 0

0.0.1 2026-03-25 17:53 UTC

This package is auto-updated.

Last update: 2026-03-25 21:07:19 UTC


README

Interfaces for caching --- defines how data is stored, retrieved, and expired, not how the backend works.

Installation

composer require marko/cache

Note: You typically install a driver package (like marko/cache-file) which requires this automatically.

Quick Example

use Marko\Cache\Contracts\CacheInterface;

class ProductService
{
    public function __construct(
        private CacheInterface $cache,
    ) {}

    public function getProduct(int $id): Product
    {
        $key = "product.$id";

        if ($this->cache->has($key)) {
            return $this->cache->get($key);
        }

        $product = $this->repository->find($id);
        $this->cache->set($key, $product, ttl: 3600);

        return $product;
    }
}

Documentation

Full usage, API reference, and examples: marko/cache