Stores
Last updated
Was this helpful?
Last updated
Was this helpful?
Stores are objects that implement READ/UPDATE/DELETE operations against a storage medium for objects that implement the interface. In a nutshell, an object is storable if it has an ID (see the and for a simple implementation). All classes belonging to the Storage namespace can be found .
There are 3 stores that the Foundations Module comes with:
for storing objects in-memory during the current request.
for persistent database storage across requests in the WP options table.
for persistent database storage across request in the WP user meta table.
Here is a simple example of a dummy storable object stored in a memory store:
There is no guarantee that your storable object will be stored properly when using the options or user meta stores. The two stores rely on WordPress' own and functions respectively and those both rely on PHP's function. If you have trouble storing your objects, implement the magic methods __serialize
and __unserialize
for better handling.