oxhq/cachelet-model

Eloquent model integration for Cachelet.

Maintainers

Package info

github.com/oxhq/cachelet-model

Homepage

Issues

pkg:composer/oxhq/cachelet-model

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

v0.2.2 2026-04-24 15:17 UTC

This package is auto-updated.

Last update: 2026-04-25 09:51:10 UTC


README

Read-only split of the Cachelet monorepo package at packages/cachelet-model.

Eloquent model integration for Cachelet.

Install

composer require oxhq/cachelet-model

Features

  • Cachelet::forModel($model)
  • $model->cachelet()
  • scope(...) for explicit intervention boundaries
  • only(), exclude(), withDates(), withTimestamps()
  • Observer-driven invalidation
  • Canonical module = model coordinates and telemetry

Example

use Oxhq\Cachelet\ValueObjects\CacheScope;
use Oxhq\Cachelet\Traits\UsesCachelet;

class User extends Model
{
    use UsesCachelet;
}

$scope = /* CacheScope instance for the intervention boundary */;

$profile = $user->cachelet()
    ->scope($scope)
    ->exclude(['updated_at'])
    ->remember(fn () => $user->fresh());

If you do not define a scope explicitly, cachelet-model infers one from the model cache prefix boundary it already uses for invalidation.