Download the PHP package kai-init/laravel-normcache without Composer

On this page you can find all versions of the php package kai-init/laravel-normcache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-normcache

Laravel Normcache

Normalized, self-invalidating Redis caching for Laravel Eloquent.

Tests Latest Version on Packagist

Normcache caches model-query results as ID lists and stores model attributes in versioned model keys. When a model changes, Normcache bumps a version key instead of scanning and deleting every query that may have returned that model.

Requirements: PHP 8.2+, Laravel 12/13, Redis 6.0+

Table of Contents

Installation

Add Cacheable to models you want Normcache to manage:

What's new in v3

Redis Cluster sharding is now fully atomic within each cache space. Normcache keeps the keys for a cached operation and its valid dependencies in one hash slot, so cache reads, rebuilds, and invalidation coordination remain atomic.

Usage

Normal Eloquent reads are cached automatically for cacheable models:

Use withoutCache() or ttl() per query:

Cross-table queries

Simple whereHas / whereDoesntHave constraints on cacheable relations and plain string joins with an explicit root-table projection are inferred automatically:

For other cross-table reads, declare dependencies explicitly:

dependsOnTables() declares a read dependency only. If that table is changed outside Eloquent, call NormCache::invalidateTableVersion($connection, $table) after the write.

Aggregates and relationships

count, exists, value, pluck, sum, avg, min, max, pagination totals, and withCount / withSum / withAvg / withMin / withMax / withExists are cached when their dependencies are safe.

Eager-loaded BelongsTo, BelongsToMany, MorphTo, MorphToMany, MorphedByMany, HasManyThrough, and HasOneThrough relations are cached. attach, detach, sync, and updateExistingPivot invalidate the relevant pivot cache.

Invalidation

Eloquent writes on cacheable models invalidate automatically. For manual invalidation:

If you mutate cacheable tables outside Eloquent, flush the affected model or table version yourself:

Tags can group query entries for manual flushing:

Cache spaces

Cache spaces are Normcache's Redis Cluster sharding boundary. Each space has a Redis hash tag, so a cached operation stays within one Cluster slot.

Models without a declaration use the default space ({nc}). Declare named spaces with $normCacheSpaces:

How space resolution works:

Dependencies must belong to the active space:

If a model dependency is not valid in the active space, Normcache bypasses the cache by default. Set spaces.cross_space_behavior to throw to fail loudly during development. Raw table dependencies from dependsOnTables() can be used in any active space and are invalidated with invalidateTableVersion().

Configure placement when you need to control Redis Cluster hash tags:

Configuration

Publish config/normcache.php if you need to customize runtime behavior:

Common options:

Option Purpose
connection Redis connection name. Default: cache.
enabled Master on/off switch.
ttl Model attribute key lifetime.
query_ttl Query/result/pivot/through key lifetime.
key_prefix Prefix for all Normcache Redis keys.
cooldown Debounce version bumps for write-heavy models.
building_lock_ttl Cache rebuild lock lifetime.
stampede_wait_ms How long waiters block for a rebuild wake signal.
stampede_wake_tokens Number of waiters to wake after a rebuild.
fallback Fail open to the database on Redis errors when true.
events Dispatch hit/miss/bypass, metric, and invalidation events.
fire_retrieved Fire Eloquent retrieved for cached models when true.
debugbar Enable Laravel Debugbar integration when installed.
spaces.* Cache-space limits, cross-space policy, and hash-tag placement.

Bypasses and limitations

Normcache bypasses caching for unsafe reads rather than risking stale or incorrect data.

Always bypassed:

Usually require dependsOn() or dependsOnTables():

Other limitations:

Observability

When events are enabled, Normcache dispatches cache hit, miss, bypass, metric, and invalidation events. When fruitcake/laravel-debugbar is installed and normcache.debugbar is enabled, cache hits, misses, bypasses, and model fetches appear in Debugbar.

License

MIT


All versions of laravel-normcache with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kai-init/laravel-normcache contains the following files

Loading the files please wait ...