# defender-security/3.0.1/framework/helper/array_cache.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 3.0.1. 72 lines.

- Page: https://pluginprobe.com/plugins/defender-security/3.0.1/code/framework/helper/array_cache.php
- Raw: https://pluginprobe.com/plugins/defender-security/3.0.1/raw/framework/helper/array_cache.php
- Modified: 2020-12-28T12:52:54+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/defender-security/3.0.1/code/framework/helper/array_cache.php#L10-L20`.

```php
<?php

namespace Calotes\Helper;

use Calotes\Base\Component;

/**
 * This is runtime cache, so the cache content will be flush after each refresh
 *
 * Class Cache
 *
 * @package Calotes\Helper
 */
class Array_Cache extends Component {
	protected static $cached = array();

	/**
	 * @param $name
	 * @param $value
	 * @param null  $group
	 */
	public static function set( $name, $value, $group = null ) {
		$key                  = $name . $group;
		self::$cached[ $key ] = $value;
	}

	/**
	 * @param $name
	 * @param null $group
	 * @param null $default
	 *
	 * @return mixed|null
	 */
	public static function get( $name, $group = null, $default = null ) {
		$key = $name . $group;

		return isset( self::$cached[ $key ] ) ? self::$cached[ $key ] : $default;
	}

	/**
	 * Quick way for append new element to a cached array
	 *
	 * @param $name
	 * @param $value
	 * @param null  $group
	 */
	public static function append( $name, $value, $group = null ) {
		$data = self::get( $name, $group, array() );
		if ( is_array( $data ) ) {
			$data[] = $value;
		}
		self::set( $name, $data, $group );
	}

	/**
	 * @param $name
	 * @param null $group
	 *
	 * @return bool
	 */
	public static function remove( $name, $group = null ) {
		$key = $name . $group;
		if ( isset( self::$cached[ $key ] ) ) {
			unset( self::$cached[ $key ] );

			return true;
		}

		return false;
	}
}

```
