Download the PHP package noga-ng/ncache without Composer

On this page you can find all versions of the php package noga-ng/ncache. 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 ncache

NCache

CI PHP PHPStan PHPUnit PHP-CS-Fixer Version

A lightweight, multi-driver caching library for PHP 8.1+.

NCache provides a unified caching API for file-based storage, SQLite, Redis, and Memcached while keeping profiles, TTL, namespaces, signatures, tags, metadata, and cache invalidation consistent across drivers.

NCache also provides PSR-6 and PSR-16 adapters for applications and libraries that rely on standard PHP-FIG caching interfaces.

Features

Requirements

Depending on the selected driver:

Installation

Quick Start

Create a configuration file:

Load the configuration and select a profile:

Store a value:

Retrieve it:

Check whether it exists:

Delete it:

Callable Values

NCache supports callables for dynamically resolved cache values.

Instead of resolving a value before passing it to NCache:

a callable can be passed directly:

Callables are also supported by append():

Signatures can also be dynamically resolved:

and validated against the current resource state:

Callable support is part of the native NCache API and is also available when values pass through the PSR adapters.

PSR Compatibility

NCache provides compatibility adapters for the standard PHP-FIG caching interfaces without coupling the native API to PSR-specific behavior.

PSR-16 — Simple Cache

NCache implements Psr\SimpleCache\CacheInterface through the SimpleCache adapter.

PSR-16 provides a portable key/value caching API with TTL, multiple operations, deletion, and cache clearing.

Read the PSR-16 documentation

PSR-6 — Caching Interface

NCache implements:

Create a cache pool:

Retrieve and store an item:

PSR-6 also supports deferred persistence:

Read the PSR-6 documentation

Which API Should I Use?

API Recommended for
Native NCache Full NCache functionality including tags, signatures, namespaces, callables, and driver control
PSR-16 Simple and portable key/value caching
PSR-6 Libraries and frameworks requiring cache items and cache pools

The PSR adapters are compatibility layers. They do not replace or restrict the native NCache API.

Configuration

NCache uses a JSON configuration file containing one or more cache profiles.

Select a profile:

Profile Isolation

When NCache::key() creates a cache instance, NCache captures the resolved state of the currently selected profile.

Changing the active profile later does not mutate cache instances that were already created.

The resulting instances remain independent:

A later call to use() does not switch the configuration of either existing cache instance.

Cache identity also includes the active profile, preventing identical cache keys from colliding when multiple profiles share the same cache directory.

Relative Cache Paths

Relative cachePath values are resolved from the directory containing the configuration file, not from the application's current working directory.

Example:

With:

NCache resolves the path relative to config/ncache.config.json.

Cache Drivers

A profile can define its default driver:

The driver can then be omitted:

A driver can also be selected explicitly:

An explicitly provided driver takes precedence over defaultDriver.

PHP Array Cache

CType::ARRAY_PHP stores cache data as a PHP file returning an array.

The generated cache is equivalent to:

Because the generated cache is loaded as PHP, this driver can benefit from PHP OPcache instead of requiring JSON decoding or unserialization for each read.

Configure the extension with:

TTL

NCache distinguishes between persistent cache, configured default TTL, and explicit TTL.

Persistent Cache

If ttl() is not called:

the cache has no expiration.

Default TTL

Calling ttl() without a value uses the active profile's defaultTtl:

Explicit TTL

Passing a TTL explicitly overrides the configured default:

Human-readable TTL

Configuration files support duration expressions:

Examples:

A numeric TTL can also be used:

Use null when no default TTL should be defined.

Namespaces and Scopes

Each profile can define a namespace:

A cache operation can also use an additional directory or scope:

For file-based drivers, the scope is resolved below the configured cachePath.

This allows identical keys to remain isolated between different profiles or cache scopes.

Shared Driver Configuration

driversFrom allows a profile to reuse Redis and Memcached connection settings from another profile.

The inherited driver configuration is resolved into the selected profile state.

Redis

Redis configuration is defined in drivers.redis:

The database option selects the Redis database used by the connection.

Memcached

Memcached configuration is defined in drivers.memcached:

Cache Tags

Tags allow multiple cache entries to be grouped logically and invalidated together without depending on a specific cache driver.

Attach one tag:

Attach multiple tags:

The registry stores tag metadata with the cache entry:

Tag Invalidation

Invalidate every cache entry associated with a tag:

Tag invalidation is intentionally lazy.

invalidateTag() does not immediately delete the underlying cached value. Matching registry entries are marked as invalid:

The next get() or has() detects the invalid tag state, deletes the cached value through its own driver, and removes the corresponding registry entry.

This keeps tag invalidation independent from the storage backend and gives file caches, SQLite, Redis, and Memcached the same invalidation lifecycle.

Tags are intentionally separate from TTL and signatures:

Cache Signatures

A signature associates cached data with the state or version of another resource.

Validate it later:

Signatures also support callables:

The current state can then be resolved dynamically during validation:

For file-based cache entries, registry metadata such as stored file size can also be used as an additional consistency check.

Append Data

Append data to an existing cache value:

append() also accepts a callable:

TTL Information

Retrieve the remaining TTL:

Inspect the TTL state:

Registry

NCache maintains cache metadata independently from the cached value.

Registry metadata includes:

Registry mutations use an exclusive lock around the complete read-modify-write cycle, reducing lost updates when multiple processes modify the same registry concurrently.

Atomic File Writes

File-based drivers write cache data through a temporary file and replace the final target only after the write is complete.

This avoids exposing partially written cache files during normal writes.

The registry uses a separate stable lock file so the registry file itself can still be replaced atomically.

Lazy Directory Iteration

Recursive cache-directory traversal is performed lazily using PHP iterators and generators.

Entries are yielded progressively instead of first collecting the entire directory tree into an in-memory array.

This keeps directory operations more memory-efficient when working with a large number of cache files.

Clearing Cache

Clear caches for the default driver:

Clear a specific driver:

Clear a specific scope:

Supported Drivers

Driver CType
JSON CType::JSON
Serialized PHP CType::SERIALIZE
String CType::STRING
PHP Array CType::ARRAY_PHP
SQLite CType::SQLite
Redis CType::REDIS
Memcached CType::MEMCACHED

PSR

Cache API

Storage

Quality

NCache is developed and tested with:

Continuous integration validates NCache on:

The CI suite also validates Redis and Memcached integration.

License

NCache is released under the MIT License.


All versions of ncache with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
psr/cache Version ^3.0
psr/simple-cache Version ^3.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 noga-ng/ncache contains the following files

Loading the files please wait ...