<commit_before><?php

namespace mako\cache;

use \Closure;

/**
* Cache adapter.
*
* @author     <NAME>
* @copyright  (c) 2008-2012 <NAME>
* @license    http://www.makoframework.com/license
*/

abstract class Adapter
{
	//---------------------------------------------
	// Class variables
	//---------------------------------------------

	/**
	* Cache identifier.
	*
	* @var string
	*/

	protected $identifier;

	//---------------------------------------------
	// Class constructor, destructor etc ...
	//---------------------------------------------

	/**
	* Constructor.
	*
	* @access  public
	* @param   string  Cache identifier
	*/
	
	public function __construct($identifier)
	{
		$this->identifier = md5($identifier);
	}

	//---------------------------------------------
	// Class methods
	//---------------------------------------------

	abstract public function write($key, $value, $ttl = 0);

	abstract public function read($key);

	abstract public function delete($key);

	abstract public function clear();

	/**
	* Store multiple variables in the cache.
	*
	* @access  public
	* @param   array    An array of cache keys
	* @param   int      (optional) Time to live
	* @return  boolean
	*/

	final public function writeMulti(array $items, $ttl = 0)
	{
		$success = true;
		
		foreach($items as $key => $value)
		{
			if($this->write($key, $value, $ttl) === false)
			{
				$success = false;
			}
		}

		return $success;
	}

	/**
	* Fetch multiple variables from the cache.
	*
	* @access  public
	* @param   array   An array of cache keys
	* @return  array
	*/

	final public function readMulti(array $keys)
	{
		$cache = array();

		foreach($keys as $key)
		{
			$cache[$key] = $this->read($key);
		}

		return $cache;
	}
	
	/**
	* Delete multiple variables from the cache.
	*
	* @access  public
	* @param   array    An array of cache keys
	* @return  boolean
	*/
	
	final public function deleteMulti(array $keys)
	{
		$success = true;
		
		foreach($keys as $key)
		{
			if($this->delete($key) === false)
			{
				$success = false;
			}
		}

		return $success;
	}

	/**
	* Fetches variable from cache and stores it if it doesn't exist.
	*
	* @access  public
	* @param   string   Cache key
	* @param   closure  Closure (anonymous function) that returns value to store if it doesn't already exist
	* @param   int      (optional) Time to live
	* @return  mixed
	*/
	
	final public function remember($key, Closure $closure, $ttl = 0)
	{
		$item = $this->read($key);
		
		if($item === false)
		{
			$item = call_user_func($closure);
			
			$this->write($key, $item, $ttl);
		}<commit_msg>Removed multi methods from cache adapter<commit_after><?php

namespace mako\cache;

use \Closure;

/**
* Cache adapter.
*
* @author     <NAME>
* @copyright  (c) 2008-2012 <NAME>
* @license    http://www.makoframework.com/license
*/

abstract class Adapter
{
	//---------------------------------------------
	// Class variables
	//---------------------------------------------

	/**
	* Cache identifier.
	*
	* @var string
	*/

	protected $identifier;

	//---------------------------------------------
	// Class constructor, destructor etc ...
	//---------------------------------------------

	/**
	* Constructor.
	*
	* @access  public
	* @param   string  Cache identifier
	*/
	
	public function __construct($identifier)
	{
		$this->identifier = md5($identifier);
	}

	//---------------------------------------------
	// Class methods
	//---------------------------------------------

	abstract public function write($key, $value, $ttl = 0);

	abstract public function read($key);

	abstract public function delete($key);

	abstract public function clear();

	/**
	* Fetches variable from cache and stores it if it doesn't exist.
	*
	* @access  public
	* @param   string   Cache key
	* @param   closure  Closure (anonymous function) that returns value to store if it doesn't already exist
	* @param   int      (optional) Time to live
	* @return  mixed
	*/
	
	final public function remember($key, Closure $closure, $ttl = 0)
	{
		$item = $this->read($key);
		
		if($item === false)
		{
			$item = call_user_func($closure);
			
			$this->write($key, $item, $ttl);
		}
{'fraction_non_alphanumeric': 0.25396825396825395, 'fraction_numerical': 0.005531505531505531, 'mean_word_length': 1.7931497649429147, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3375850', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1231, 'n_words': 353}