M2: OPCache GUI

Now you can easily view the statistics for PHP OPcache in your Magento admin panel. TCMP OPcache GUI displays current memory usage / hit rate / configuration values. You can optionally enable the display of all cached scripts, including details about them, and a quick reset link for the menu (Stores > Configuration > TCMP Studio > OPcache).

Installation:


composer require tcmp/opcache
php bin/magento module:enable TCMP_OpCache
php bin/magento setup:updgrade
php bin/magento setup:static-content:deploy

Example:

TCMP OPcache GUI Example

More Information:

Supports: Magento 2.x (System Requirements) / PHP 7.x (OPCache Documentation)
The source: https://github.com/theycallmepepper/m2-opcache-gui
Packagist listing: https://packagist.org/packages/tcmp/opcache

Charts built with Chart.js
Version for Magento 1 (and inspiration for this version): https://github.com/SchumacherFM/Magento-OpCache/

M2: Invalidating Caches

When saving objects in your custom module it may be beneficial to indicate that a cache type should be cleared.  This can be achieved using the TypeListInterface from the Framework’s Cache Module. Furthermore with this interface you can also retrieve the cache type labels, a list of other caches that have been invalidated, or clean a cache type by code.

<?php

namespace Vendor\Module\Folder;

use Magento\Framework\App\Cache\TypeListInterface;

/**
 * Class Example
 *
 * @package Vendor\Module\Folder
 */
class Example {

   /**
   * @var TypeListInterface
   */
   protected $_cacheTypesList;

   /**
    * Example constructor.
    *
    * @param TypeListInterface $_cacheTypesList
    */
   public function __construct( TypeListInterface $_cacheTypesList )
   {
      $this->_cacheTypesList = $_cacheTypesList;
   }

   /**
    * Mark specific cache type(s) as invalidated
    *
    * @param $type
    */
   public function invalidateCache( $type )
   {
      $this->_cacheTypesList->invalidate( $type );
   }

   /**
    * Get information about all declared cache types
    *
    * @return array
    */
   public function getCacheTypes()
   {
      /* Example structure for cache type array
       $_types = [
         'CACHE TYPE CODE' =>
          (object)[ //Magento\Framework\DataObject
                    'id' =>(int)'',
                    'cache_type'=>(string) '',
                    'description'=>(string)'',
                    'tags'=>(string)'',
                     'status'=>(int)'',
             ]
      ];*/
      return $this->_cacheTypesList->getTypes();
   }

}