GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - php-cache/namespaced-cache: [READ-ONLY] A library to make a PSR-6 cache prefixed with a namespace.

BranchesTags
Open more actions menu

Latest commit

 

History

49 Commits
49 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
Exception
Exception
 
 
Tests
Tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
Changelog.md
Changelog.md
 
 
LICENSE
LICENSE
 
 
NamespacedCacheItem.php
NamespacedCacheItem.php
 
 
NamespacedCachePool.php
NamespacedCachePool.php
 
 
NamespacedTagMapper.php
NamespacedTagMapper.php
 
 
README.md
README.md
 
 
TaggableNamespacedCacheItem.php
TaggableNamespacedCacheItem.php
 
 
TaggableNamespacedCachePool.php
TaggableNamespacedCachePool.php
 
 
composer.json
composer.json
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

Namespaced PSR-6 cache pool

Latest Stable Version Coverage Software License

This package limits a PSR-6 pool to one namespace. Calling clear() invalidates that namespace without clearing unrelated data.

Installation

composer require cache/namespaced-cache:^2.0

Usage

use Cache\Adapter\PHPArray\ArrayCachePool;
use Cache\Namespaced\NamespacedCachePool;

$sharedPool = new ArrayCachePool();
$pool = NamespacedCachePool::create($sharedPool, 'billing');

Namespaces must contain at least one character. The constructor and create() reject an empty namespace.

create() returns a taggable decorator when the wrapped pool supports native tags. Its cache items keep setTags(). Tag indexes are scoped to the namespace, while getPreviousTags() continues to return the public tag names.

A hierarchical pool handles namespace invalidation through its native hierarchy. Other PSR-6 pools use generation keys, so old values remain stored until the backend evicts them.

The decorator persists a random generation before deriving storage keys. If the backend loses that metadata, the decorator stores a new generation instead of reusing an earlier key.

Generation records are typed. If an unrelated value occupies the first internal metadata key, the decorator probes alternate keys instead of overwriting it.

This prevents a cleared value from becoming visible after generation metadata expires or gets evicted. The decorator throws CacheException if it cannot persist new metadata.

Keys that start with | keep hierarchical deletion on every wrapped pool. Deleting |parent invalidates that key and its descendants without changing sibling or ordinary keys.

Deleting the hierarchy root | invalidates every hierarchical key in the namespace. Ordinary keys that do not start with | remain available.

Both deleteItem() and deleteItems() apply these hierarchy rules.

The public constructor remains available. It always returns the basic NamespacedCachePool type, so use create() when you need tag support.

Version 2 encodes namespace components with a reversible _xHH_ byte format. ASCII letters, digits, _, and . remain unchanged. Every other byte is encoded, including each byte in non-ASCII text. A literal lowercase _x sequence is also encoded so it cannot look like an encoded byte.

Public key components keep ordinary bytes accepted by the wrapped pool, including -, %, and non-ASCII text. Only the structural | and ! bytes and a literal lowercase _x sequence are encoded.

Before upgrading or rolling back, clear affected namespaces when a namespace contains bytes outside [A-Za-z0-9_.] or a lowercase _x sequence, or when a public key contains |, !, or a lowercase _x sequence.

Version 2 also scopes internal tag indexes to each namespace. Clear existing namespaced caches that contain tagged items before deploying this version or rolling back from it.

Version 2 preserves ordinary items in nested namespaces. Public hierarchy keys now use a separate storage path to prevent collisions with those items.

Clear existing namespaced caches that contain hierarchy keys before upgrading or rolling back. Pre-version-4 hierarchy entries use the same storage path as some nested items.

Contributing

Send pull requests to the main repository. Report issues on the GitHub issue tracker.

About

[READ-ONLY] A library to make a PSR-6 cache prefixed with a namespace.

www.php-cache.com

Resources

Readme
MIT license
Activity
Custom properties

Stars

14 stars

Watchers

3 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.