# woocommerce-pos/1.9.16/includes/Services/Cache.php

WCPOS – Point of Sale (POS) plugin for WooCommerce, version 1.9.16. 58 lines.

- Page: https://pluginprobe.com/plugins/woocommerce-pos/1.9.16/code/includes/Services/Cache.php
- Raw: https://pluginprobe.com/plugins/woocommerce-pos/1.9.16/raw/includes/Services/Cache.php
- Modified: 2026-02-06T20:51:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woocommerce-pos/1.9.16/code/includes/Services/Cache.php#L10-L20`.

```php
<?php
/**
 * Cache Helper class
 *
 * @package WCPOS\WooCommercePOS
 */

namespace WCPOS\WooCommercePOS\Services;

use WCPOS\Vendor\Phpfastcache\Drivers\Files\Config;
use WCPOS\Vendor\Phpfastcache\Drivers\Files\Driver;
use WCPOS\Vendor\Phpfastcache\EventManager;
use WCPOS\Vendor\Phpfastcache\Helper\Psr16Adapter;

/**
 * Cache class.
 */
class Cache {
	/**
	 * Get the cache instance
	 *
	 * @param string $instance_id Instance ID.
	 *
	 * @return Psr16Adapter|object
	 */
	public static function get_cache_instance( string $instance_id = 'default' ) {
		static $cache = null;

		if ( null === $cache ) {
			$upload_dir = wp_upload_dir();
			$cache_dir = $upload_dir['basedir'] . '/woocommerce_pos_cache';

			if ( ! file_exists( $cache_dir ) ) {
				wp_mkdir_p( $cache_dir );
			}

			// @phpstan-ignore-next-line.
			$config = new Config(
				array(
					'path' => $cache_dir,
				)
			);

			$event_manager = EventManager::getInstance();

			// Generate a unique instance ID for each logged-in user.
			// @phpstan-ignore-next-line.
			$driver = new Driver( $config, $instance_id );
			$driver->setEventManager( $event_manager );

			// @phpstan-ignore-next-line.
			$cache = new Psr16Adapter( $driver );
		}

		return $cache;
	}
}

```
