<commit_before><?php

abstract class BasePhpFastCache {

    var $tmp = array();

    // default options, this will be merge to Driver's Options
    var $config = array();


    var $fallback = false;
    var $instant;

    /*
     * Basic Functions
     */

    public function set($keyword, $value = "", $time = 0, $option = array() ) {
        /*
         * Infinity Time
         * Khoa. B
         */
        if((Int)$time <= 0) {
            // 5 years, however memcached or memory cached will gone when u restart it
            // just recommended for sqlite. files
            $time = 3600*24*365*5;
        }
        /*
         * Temporary disabled phpFastCache::$disabled = true
         * Khoa. B
         */
        if(phpFastCache::$disabled === true) {
            return false;
        }
        $object = array(
            "value" => $value,
            "write_time"  => time(),
            "expired_in"  => $time,
            "expired_time"  => time() + (Int)$time,
        );

        return $this->driver_set($keyword,$object,$time,$option);

    }

    public function get($keyword, $option = array()) {
        /*
       * Temporary disabled phpFastCache::$disabled = true
       * Khoa. B
       */

        if(phpFastCache::$disabled === true) {
            return null;
        }

        $object = $this->driver_get($keyword,$option);

        if($object == null) {
            return null;
        }
		
		$value = isset( $object['value'] ) ? $object['value'] : null;
		return isset( $option['all_keys'] ) && $option['all_keys'] ? $object : $value;
    }


    function getInfo($keyword, $option = array()) {
        $object = $this->driver_get($keyword,$option);

        if($object == null) {
            return null;
        }
        return $object;
    }

    function delete($keyword, $option = array()) {
        return $this->driver_delete($keyword,$option);
    }

    function stats($option = array()) {
        return $this->driver_stats($option);
    }

    function clean($option = array()) {
        return $this->driver_clean($option);
    }

    function isExisting($keyword) {
        if(method_exists($this,"driver_isExisting")) {
            return $this->driver_isExisting($keyword);
        }

        $data = $this->get($keyword);
        if($data == null) {
            return false;
        } else {
            return true;
        }

    }

    // Searches though the cache for keys that match the given query.
    // todo: search
    function search($query) {
        if(method_exists($this,"driver_search")) {
            return $this->driver_search($query);
        }
        throw new Exception('Search method is not supported by this driver.');
    }

    function increment($keyword, $step = 1 , $option = array()) {
        $object = $this->get($keyword, array('all_keys' => true));
        if($object == null) {
            return false;
        } else {
            $value = (Int)$object['value'] + (Int)$step;
            $time = $object['expired_time'] - time();
            $this->set($keyword,$value, $time, $option);
            return true;
        }
    }

    function decrement($keyword, $step = 1 , $option = array()) {
        $object = $this->get($keyword, array('all_keys' => true));
        if($object == null) {
            return false;
        } else {
            $value = (Int)$object['value'] - (Int)$step;
            $time = $object['expired_time'] - time();
            $this->set($keyword,$value, $time, $option);
            return true;
        }
    }
    /*
     * Extend more time
     */
    function touch($keyword, $time = 300, $option = array()) {
        $object = $this->get($keyword, array('all_keys' => true));
        if($object == null) {
            return false;
        } else {
            $value = $object['value'];
            $time = $object['expired_time'] - time() + $time;
            $this->set($keyword, $value,$time, $option);
            return true;
        }
    }


    /*
    * Other Functions Built-int for phpFastCache since 1.3
    */

    public function setMulti($list = array()) {
        foreach($list as $array) {
            $this->set($array[0], isset($array[1]) ? $array[1] : 0, isset($array[2]) ? $array[2] : array());
        }
    }

    public function getMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->get($name, isset($array[1]) ? $array[1] : array());
        }
        return $res;
    }

    public function getInfoMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->getInfo($name, isset($array[1]) ? $array[1] : array());
        }
        return $res;
    }

    public function deleteMulti($list = array()) {
        foreach($list as $array) {
            $this->delete($array[0], isset($array[1]) ? $array[1] : array());
        }
    }

    public function isExistingMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->isExisting($name);
        }
        return $res;
    }

    public function incrementMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->increment($name, $array[1], isset($array[2]) ? $array[2] : array());
        }
        return $res;
    }

    public function decrementMulti($list = array()) {
        $res = array();<commit_msg>Fixed issue #175<commit_after><?php

abstract class BasePhpFastCache {

    var $tmp = array();

    // default options, this will be merge to Driver's Options
    var $config = array();


    var $fallback = false;
    var $instant;

    /*
     * Basic Functions
     */

    public function set($keyword, $value = "", $time = 0, $option = array() ) {
        /*
         * Infinity Time
         * Khoa. B
         */
        if((Int)$time <= 0) {
            // 5 years, however memcached or memory cached will gone when u restart it
            // just recommended for sqlite. files
            $time = 3600*24*365*5;
        }
        /*
         * Temporary disabled phpFastCache::$disabled = true
         * Khoa. B
         */
        if(phpFastCache::$disabled === true) {
            return false;
        }
        $object = array(
            "value" => $value,
            "write_time"  => time(),
            "expired_in"  => $time,
            "expired_time"  => time() + (Int)$time,
        );

        return $this->driver_set($keyword,$object,$time,$option);

    }

    public function get($keyword, $option = array()) {
        /*
       * Temporary disabled phpFastCache::$disabled = true
       * Khoa. B
       */

        if(phpFastCache::$disabled === true) {
            return null;
        }

        $object = $this->driver_get($keyword,$option);

        if($object == null) {
            return null;
        }
		
		$value = isset( $object['value'] ) ? $object['value'] : null;
		return isset( $option['all_keys'] ) && $option['all_keys'] ? $object : $value;
    }


    function getInfo($keyword, $option = array()) {
        $object = $this->driver_get($keyword,$option);

        if($object == null) {
            return null;
        }
        return $object;
    }

    function delete($keyword, $option = array()) {
        return $this->driver_delete($keyword,$option);
    }

    function stats($option = array()) {
        return $this->driver_stats($option);
    }

    function clean($option = array()) {
        return $this->driver_clean($option);
    }

    function isExisting($keyword) {
        if(method_exists($this,"driver_isExisting")) {
            return $this->driver_isExisting($keyword);
        }

        $data = $this->get($keyword);
        if($data == null) {
            return false;
        } else {
            return true;
        }

    }

    // Searches though the cache for keys that match the given query.
    // todo: search
    function search($query) {
        if(method_exists($this,"driver_search")) {
            return $this->driver_search($query);
        }
        throw new Exception('Search method is not supported by this driver.');
    }

    function increment($keyword, $step = 1 , $option = array()) {
        $object = $this->get($keyword, array('all_keys' => true));
        if($object == null) {
            return false;
        } else {
            $value = (Int)$object['value'] + (Int)$step;
            $time = $object['expired_time'] - time();
            $this->set($keyword,$value, $time, $option);
            return true;
        }
    }

    function decrement($keyword, $step = 1 , $option = array()) {
        $object = $this->get($keyword, array('all_keys' => true));
        if($object == null) {
            return false;
        } else {
            $value = (Int)$object['value'] - (Int)$step;
            $time = $object['expired_time'] - time();
            $this->set($keyword,$value, $time, $option);
            return true;
        }
    }
    /*
     * Extend more time
     */
    function touch($keyword, $time = 300, $option = array()) {
        $object = $this->get($keyword, array('all_keys' => true));
        if($object == null) {
            return false;
        } else {
            $value = $object['value'];
            $time = $object['expired_time'] - time() + $time;
            $this->set($keyword, $value,$time, $option);
            return true;
        }
    }


    /*
    * Other Functions Built-int for phpFastCache since 1.3
    */

    public function setMulti($list = array()) {
        foreach($list as $array) {
            $this->set($array[0], isset($array[1]) ? $array[1] : 0, isset($array[2]) ? $array[2] : array());
        }
    }

    public function getMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->get($name, isset($array[1]) ? $array[1] : array());
        }
        return $res;
    }

    public function getInfoMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->getInfo($name, isset($array[1]) ? $array[1] : array());
        }
        return $res;
    }

    public function deleteMulti($list = array(), $option = array()) {
        foreach($list as $item) {
            if(is_array($item) && count($item) === 2){
                $this->delete($item[0], $item[1]);
            }else if(is_string($item)){
                $this->delete($item, $option);
            }else{
                throw new Exception('Invalid values passed to deleteMulti()');
            }
        }
    }

    public function isExistingMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->isExisting($name);
        }
        return $res;
    }

    public function incrementMulti($list = array()) {
        $res = array();
        foreach($list as $array) {
            $name = $array[0];
            $res[$name] = $this->increment($name, $array[1], isset($array[2]) ? $array[2] : array());
        }
        return $res;
    }

    public function decrementMulti($list = array()) {
        $res = array();
{'fraction_non_alphanumeric': 0.16523642732049038, 'fraction_numerical': 0.007267950963222417, 'mean_word_length': 1.8488401097530556, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 60, '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': '4868931', 'n_tokens_mistral': 3411, 'n_tokens_neox': 3305, 'n_words': 764}