PHP Class MatthiasMullie\Scrapbook\Buffered\Utils\Buffer

The memory-part can easily be handled by MemoryStore. There's just 1 gotcha: when an item is to be deleted (but not yet committed), it needs to be deleted from the MemoryStore too, but we need to be able to make a distinction between "this is deleted" and "this value is not known in this memory cache, fall back to real cache". This is where this class comes in to play: we'll add an additional "expired" method, which allows BufferedStore to just expire the keys that are supposed to be deleted (instead of deleting them) - then we can keep track of when a key is just not known, or known-but-deleted (=expired)
Author: Matthias Mullie ([email protected])
Inheritance: extends MatthiasMullie\Scrapbook\Adapters\MemoryStore
Afficher le fichier Open project: matthiasmullie/scrapbook Class Usage Examples

Méthodes publiques

Méthode Description
expired ( string $key ) : boolean Check if a key existed in local storage, but is now expired.

Méthodes protégées

Méthode Description
exists ( string $key ) : boolean Checks if a value exists in cache and is not yet expired.

Method Details

exists() protected méthode

Contrary to default MemoryStore, expired items must *not* be deleted from memory: we need to remember that they were expired, so we don't reach out to real cache (only to get nothing, since it's expired...).
protected exists ( string $key ) : boolean
$key string
Résultat boolean

expired() public méthode

Because our local buffer is also just a real cache, expired items will just return nothing, which will lead us to believe no such item exists in that local cache, and we'll reach out to the real cache (where the value may not yet have been expired because that may have been part of an uncommitted write) So we'll want to know when a value is in local cache, but expired!
public expired ( string $key ) : boolean
$key string
Résultat boolean