PHP code example of pulkitjalan / multicache

1. Go to this page and download the library: Download pulkitjalan/multicache 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/ */

    

pulkitjalan / multicache example snippets


PulkitJalan\Cache\Providers\MultiCacheServiceProvider::class

    /**
     * Determine if an array of items exists in the cache.
     *
     * @param  array  $keys
     * @return array
     */
    public function hasMany(array $keys);

    /**
     * Retrieve an array of items from the cache by keys.
     *
     * @param  array  $keys
     * @param  mixed  $default
     * @return array
     */
    public function getMany(array $keys, $default = null);

    /**
     * Retrieve an array of items from the cache and delete them.
     *
     * @param  array  $keys
     * @param  mixed  $default
     * @return array
     */
    public function pullMany(array $keys, $default = null);

    /**
     * Store an array of items in the cache.
     *
     * @param  array  $items
     * @param  \DateTime|int  $minutes
     * @return void
     */
    public function putMany(array $items, $minutes);

    /**
     * Store an array of items in the cache if the key does not exist.
     *
     * @param  array  $items
     * @param  \DateTime|int  $minutes
     * @return bool
     */
    public function addMany(array $items, $minutes);

    /**
     * Store an array of items in the cache indefinitely.
     *
     * @param  array  $items
     * @return void
     */
    public function foreverMany(array $items);

    /**
     * Get an array of items from the cache, or store the default value.
     *
     * @param  array  $keys
     * @param  \DateTime|int  $minutes
     * @param  \Closure  $callback
     * @return mixed
     */
    public function rememberMany(array $keys, $minutes, Closure $callback);

    /**
     * Get an array of items from the cache, or store the default value forever.
     *
     * @param  array  $keys
     * @param  \Closure  $callback
     * @return mixed
     */
    public function searMany(array $keys, Closure $callback);

    /**
     * Get an array of items from the cache, or store the default value forever.
     *
     * @param  array  $keys
     * @param  \Closure  $callback
     * @return mixed
     */
    public function rememberManyForever(array $keys, Closure $callback);

    /**
     * Remove an array of items from the cache.
     *
     * @param  array  $keys
     * @return bool
     */
    public function forgetMany(array $keys);

$keys = [
    'one', // exists
    'two', // does not exist
    'three', // exists
];

Cache::hasMany($keys);

// or

Cache::has($keys);

// will return: ['one' => true, 'two' => false, 'three' => true]

$keys = [
    'one', // exists
    'two', // does not exist
    'three', // exists
];

Cache::getMany($keys);

// or

Cache::get($keys);

// will return: ['one' => 'data', 'two' => null, 'three' => 'data']

$data = [
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3',
];

Cache::putMany($data, 10);

// or

Cache::put(array_keys($data), array_values($data), 10);

$keys = [
    'one',
    'two',
    'three',
];

Cache::forgetMany($keys);

// or

Cache::forget($keys);

// will return: ['one' => true, 'two' => true, 'three' => true]