Skip to content

Caching

github-actions[bot] edited this page Aug 12, 2026 · 1 revision

Caching

Two things are cached through your app's default cache store via the Cache facade. The package does not configure or require a dedicated cache store.

What Is Cached

  • Model schema, including columns, casts, and enum values, is built once per model and cached for one hour.
  • Prepared requests, meaning the parsed and validated query plan keyed by a fingerprint of the request plus the model config, are cached for five minutes.

The prepared-request cache exists mainly for approvals. A request that needs approval is evaluated twice, once to decide whether to pause and once to actually run after approval, and this cache prevents the second pass from re-parsing and re-validating from scratch.

Cache Keys And Invalidation

Both caches use versioned, eloquent-ai-tools:-prefixed keys, so sharing a cache store with the rest of your app, or other apps, is safe.

The model-schema cache is refreshed on use by touching its TTL when a cached snapshot is read.

Both caches are invalidated automatically after php artisan migrate via a listener on MigrationsEnded.

If you change a model's schema some other way, such as a raw ALTER TABLE or by editing $visible, $hidden, or casts on the model, and do not want to wait for the TTL, call ModelSchemaBuilder::clearCache() yourself. That also clears the prepared-request cache.

Production Note

If your app's default cache store is the array driver, neither cache persists across requests. Everything still works correctly, but you do not get the intended performance benefit.

Use a persistent store such as file, database, or redis in production to benefit from caching.

Clone this wiki locally