<commit_before><?php
/**
 * Uses the memcached extension,
 * This requires 2 things : 
 * 	1. in the php.ini - uncomment the extension=php_memcache.dll entry (windows)
 * 	2. run the daemon memcached
 * 
 * The memcahe object is sttic and will be used for all of the cache requests of a single request.
 * 
 * @package infra
 * @subpackage cache
 */
class myCache
{
	const STATS = "_stats_";
	const DEFAULT_EXPIRY_IN_SECONDS = 0	;

	
	private $m_namespace;
	private $m_stats ;
	private $m_expiry;
	private static $s_ready = false;
	private static $s_memcache;

	// if the cache will be used many times, a default expiry can be set to avoid setting evey time in the put method
	// this is good when most objects have the same expiry time
	public function myCache ( $namespace , $expiry = NULL )
	{
		$this->m_namespace = $namespace;
		
		if ( self::$s_memcache == NULL )
		{
			self::$s_memcache = kCacheManager::getCache(kCacheManager::MC_LOCAL);
			if (self::$s_memcache)
			{
				self::$s_ready = true;
			}
		}

		
		if ( $expiry != null )
		{
			$this->m_expiry = $expiry;
		}
		
		if ( $this->calculateStats() )
		{
			$this->m_stats = $this->getStatsObj();
			if ( $this->m_stats == NULL )
			{
				$this->m_stats = new cacheStats ;
			}
		}
		else
		{
			$this->m_stats = new cacheStats ;
		}

	}
	
	static private function calculateStats()
	{
		return false;
	}
	
	private function getStatsObj ()
	{
//		self::$s_memcache->get ( $this->m_namespace . self::STATS ); 	
	}

	private function setStatsObj ()
	{
//		self::$s_memcache->set ( $this->m_namespace . self::STATS , $this->m_stats ); 	
	}
	
	
	public function put ( $obj_name , $obj , $expiry = NULL )
	{
		if ( ! self::$s_ready ) return;
		if ($expiry == NULL  )
		{
			$expiry = $this->m_expiry;
			
			// if it is still NULL
			if ($expiry == NULL  )
			{
				$expiry == self::DEFAULT_EXPIRY_IN_SECONDS;
			}
		}
		
		self::$s_memcache->set ( $this->m_namespace . $obj_name , $obj , false , $expiry );
		
		// TODO - maintain the linked_list
//		//$this->m_obj_container[$obj_name] = $obj;
		$this->m_stats->m_puts++;
	}<commit_msg>qnd: updated myCache params to match those of kCacheWrapper<commit_after><?php
/**
 * Uses the memcached extension,
 * This requires 2 things : 
 * 	1. in the php.ini - uncomment the extension=php_memcache.dll entry (windows)
 * 	2. run the daemon memcached
 * 
 * The memcahe object is sttic and will be used for all of the cache requests of a single request.
 * 
 * @package infra
 * @subpackage cache
 */
class myCache
{
	const STATS = "_stats_";
	const DEFAULT_EXPIRY_IN_SECONDS = 0	;

	
	private $m_namespace;
	private $m_stats ;
	private $m_expiry;
	private static $s_ready = false;
	private static $s_memcache;

	// if the cache will be used many times, a default expiry can be set to avoid setting evey time in the put method
	// this is good when most objects have the same expiry time
	public function myCache ( $namespace , $expiry = NULL )
	{
		$this->m_namespace = $namespace;
		
		if ( self::$s_memcache == NULL )
		{
			self::$s_memcache = kCacheManager::getCache(kCacheManager::MC_LOCAL);
			if (self::$s_memcache)
			{
				self::$s_ready = true;
			}
		}

		
		if ( $expiry != null )
		{
			$this->m_expiry = $expiry;
		}
		
		if ( $this->calculateStats() )
		{
			$this->m_stats = $this->getStatsObj();
			if ( $this->m_stats == NULL )
			{
				$this->m_stats = new cacheStats ;
			}
		}
		else
		{
			$this->m_stats = new cacheStats ;
		}

	}
	
	static private function calculateStats()
	{
		return false;
	}
	
	private function getStatsObj ()
	{
//		self::$s_memcache->get ( $this->m_namespace . self::STATS ); 	
	}

	private function setStatsObj ()
	{
//		self::$s_memcache->set ( $this->m_namespace . self::STATS , $this->m_stats ); 	
	}
	
	
	public function put ( $obj_name , $obj , $expiry = NULL )
	{
		if ( ! self::$s_ready ) return;
		if ($expiry == NULL  )
		{
			$expiry = $this->m_expiry;
			
			// if it is still NULL
			if ($expiry == NULL  )
			{
				$expiry == self::DEFAULT_EXPIRY_IN_SECONDS;
			}
		}
		
		self::$s_memcache->set ( $this->m_namespace . $obj_name , $obj , $expiry );
		
		// TODO - maintain the linked_list
//		//$this->m_obj_container[$obj_name] = $obj;
		$this->m_stats->m_puts++;
	}
{'fraction_non_alphanumeric': 0.136986301369863, 'fraction_numerical': 0.001889466225791214, 'mean_word_length': 2.9840075258701786, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4416861', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1538, 'n_words': 395}