PHP code example of devuri / ob-cache

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

    

devuri / ob-cache example snippets


  $cache = new ObCache();
  

  $cache = ObCache::init();
  

  $cache->set_cache_allowed(true); // Enable caching
  $cache->set_cache_allowed(false); // Disable caching
  

  $cache->set('cache_key', function() {
      // Data generation logic
      return $data;
  }, 3600); // 3600 seconds expiration
  

  $data = $cache->get('cache_key', function() {
      // Data generation logic
      return $data;
  }, 3600);
  

  $cache->forget('cache_key');