Download the PHP package arraypress/wp-storage-utils without Composer
On this page you can find all versions of the php package arraypress/wp-storage-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arraypress/wp-storage-utils
More information about arraypress/wp-storage-utils
Files in arraypress/wp-storage-utils
Package wp-storage-utils
Short Description The three storage operations WordPress lacks: cache-or-compute, delete-by-prefix, and reading a stored value as the type it is meant to be.
License GPL-2.0-or-later
Homepage https://github.com/arraypress/wp-storage-utils/
Informations about the package wp-storage-utils
WordPress Storage Utilities
The three storage jobs WordPress leaves you to write: cache-or-compute, delete by prefix, and reading a stored value back as the type you wanted.
What it does
get_transient() returns false both when nothing is cached and when the
cached value is false, so the cache-or-compute pattern gets written by hand,
subtly wrong, in every plugin. remember() wraps the stored value so the two
are distinguishable.
Deleting your own transients when a plugin uninstalls has no API at all, so
everyone writes a DELETE ... LIKE — usually forgetting that the timeout rows
do not carry the prefix, and leaving half of them behind forever.
And anything out of the options table is a string, so it needs casting before it is useful.
Features
- Cache-or-compute that can store
false,nullor0without confusion - Delete every option, transient or meta row sharing a prefix, on uninstall
- Remove both halves of a transient, so nothing is orphaned in
wp_options - Cast a stored value to bool, int, float, array or a list of ids
- Escapes
LIKEwildcards, so an underscore in your prefix stays literal
Installation
Quick start
Requirements
- PHP 8.3 or later
- WordPress 7.1 or later
License
GPL-2.0-or-later