PHP code example of ryanhellyer / stale-cache

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

    

ryanhellyer / stale-cache example snippets


$result = StaleCache::get(
    'my_cache_key',
    [
        5,      // Stale time in seconds
        3600,   // Cache duration in seconds
        60      // Lock duration in seconds (optional)
    ],
    function() {
        // Your expensive operation here
        return getExpensiveData();
    }
);