PHP code example of henzeb / laravel-cache-index

1. Go to this page and download the library: Download henzeb/laravel-cache-index 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/ */

    

henzeb / laravel-cache-index example snippets


Cache::index('myIndex')->add('test', 'my value');
Cache::index('myIndex')->put('put', 'my value');

Cache::driver('file')->index('myIndex')->remember('filed', 'my value in file');

Cache::index('myIndex')->get('put'); // returns 'my value'
Cache::get('put'); // returns null

Cache::index('myIndex')->flush(); // only flushes keys in index


Cache::index(['myIndex', 'Read', 'Write']); // uses index name `myIndex.Read.Write`
Cache::index(['myIndex', ActionEnum::Read]); // uses index name `myIndex.Read`
Cache::index(['myIndex', new StdClass()]); // uses index name `myIndex.StdClass`
Cache::index(['myIndex', new StringableClass('stringed')]); // uses index name `myIndex.stringed`


Cache::index('myIndex')->keys(); // returns ['test', 'put']
Cache::driver('file')->index('myIndex')->keys(); // returns ['filed']

Cache::index('myIndex'); // using default driver
Cache::driver('file')->index('myIndex'); // using file driver

Cache::index('myIndex')->copy('myKey', 'targetIndex');
Cache::index('myIndex')->copy('myKey', 'targetIndex', 10);

Cache::index('myIndex')->move('myKey', 'targetIndex');
Cache::index('myIndex')->move('myKey', 'targetIndex', 10);

Cache::index('myIndex')->syncTtl(10);
Cache::index('myIndex')->syncTtl(now()->addSeconds(10));