PHP code example of alleyinteractive / wp-psr16

1. Go to this page and download the library: Download alleyinteractive/wp-psr16 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alleyinteractive / wp-psr16 example snippets




// Cache data using transients as the datastore.
$transient = \Alley\WP\SimpleCache\Transient_Adapter::create();

// Cache data using the object cache as the datastore.
$object_cache = \Alley\WP\SimpleCache\Object_Cache_Adapter::create();

/*
 * Cache data using options as the datastore. The options are not autoloaded.
 * Using options as the datastore can be slower than using transients or the
 * object cache, but items are never evicted like in Memcache or Redis.
 */
$option = \Alley\WP\SimpleCache\Option_Adapter::create();

/*
 * Cache data using object metadata as the datastore. This allows cache items to
 * be associated with a specific post, term, or other object that supports metadata.
 * For example, you could cache an individual post's related posts. Like options,
 * using metadata as the datastore can be slower, but items are never evicted.
 */
$post_meta   = \Alley\WP\SimpleCache\Metadata_Adapter::for_post( 123 );
$term_meta   = \Alley\WP\SimpleCache\Metadata_Adapter::for_term( 123 );
$user_meta   = \Alley\WP\SimpleCache\Metadata_Adapter::create( 'user', 123 );
$custom_meta = \Alley\WP\SimpleCache\Metadata_Adapter::create( 'custom', 123 );