<commit_before><?php
/**
 * WordPress Redis Light Speed Caching Engine
 *
 * Redis caching system for WordPress. Inspired by <NAME> & <NAME>
 *
 * @author <NAME>
 * @see http://www.jeedo.net/lightning-fast-wordpress-with-nginx-redis/
 * @see http://www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/
 */

if (redis_light::cache()) {
    define('WP_USE_THEMES', true);

    ob_start([ 'redis_light', 'callback' ]);

    /** Loads the WordPress Environment and Template */
    require getcwd().'/wp-blog-header.php';

    ob_end_flush();

    /** terminate the script here **/
    die();
}

class redis_light
{
    public static $cc     = 0;    // logger step counter
    public static $key    = null; // cache key
    public static $redis  = null; // redis instance
    public static $config = null; // configuration array


    /*
     * main Redis cache method
     *
     */
    public static function cache()
    {
        self::logger(str_repeat('-', 100));
        self::logger('Starting Redis caching engine connection...');

        //
        // do not run if explicitly requested
        #if (isset($_GET['NOCACHE']) or (isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] == 'max-age=0')) {
        if (isset($_GET['NOCACHE'])) {
            self::logger('NOCACHE explicitly requested. terminating...');

            header('Cache: skipping');

            return false;
        }

        //
        // do not run if request is a POST or user is logged into WordPress
        // if ($_POST or preg_match("/wordpress_logged_in/", var_export($_COOKIE, true))) {
        //     self::logger('NOCACHE explicitly requested. terminating...');

        //     header('Cache: disengaged');

        //     return false;
        // }

        /**
         * start Redis cache processing
         *
         * 1. try to connect to redis server
         * 2. fetch or create domain host database
         * 3. define URL storage key
         *
         */
        $config = getcwd().'/wp-content/plugins/redis-wp-plugin/config.json';

        if ($config = @file_get_contents($config)) {
            self::$config = json_decode($config, true);
        }

        if (! is_array(self::$config)) {
            self::$config = self::defaults();
        }

        // self::$redis = new Redis();
        // $connect     = self::$redis->connect(self::$config['host'], self::$config['port'], self::$config['timeout']);<commit_msg>revert last change<commit_after><?php
/**
 * WordPress Redis Light Speed Caching Engine
 *
 * Redis caching system for WordPress. Inspired by <NAME> & <NAME>
 *
 * @author <NAME>
 * @see http://www.jeedo.net/lightning-fast-wordpress-with-nginx-redis/
 * @see http://www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/
 */

if (redis_light::cache()) {
    define('WP_USE_THEMES', true);

    ob_start([ 'redis_light', 'callback' ]);

    /** Loads the WordPress Environment and Template */
    require getcwd().'/wp-blog-header.php';

    ob_end_flush();

    /** terminate the script here **/
    die();
}

class redis_light
{
    public static $cc     = 0;    // logger step counter
    public static $key    = null; // cache key
    public static $redis  = null; // redis instance
    public static $config = null; // configuration array


    /*
     * main Redis cache method
     *
     */
    public static function cache()
    {
        self::logger(str_repeat('-', 100));
        self::logger('Starting Redis caching engine connection...');

        //
        // do not run if explicitly requested
        #if (isset($_GET['NOCACHE']) or (isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] == 'max-age=0')) {
        if (isset($_GET['NOCACHE'])) {
            self::logger('NOCACHE explicitly requested. terminating...');

            header('Cache: skipping');

            return false;
        }

        //
        // do not run if request is a POST or user is logged into WordPress
        if ($_POST or preg_match("/wordpress_logged_in/", var_export($_COOKIE, true))) {
            self::logger('NOCACHE explicitly requested. terminating...');

            header('Cache: disengaged');

            return false;
        }

        /**
         * start Redis cache processing
         *
         * 1. try to connect to redis server
         * 2. fetch or create domain host database
         * 3. define URL storage key
         *
         */
        $config = getcwd().'/wp-content/plugins/redis-wp-plugin/config.json';

        if ($config = @file_get_contents($config)) {
            self::$config = json_decode($config, true);
        }

        if (! is_array(self::$config)) {
            self::$config = self::defaults();
        }

        // self::$redis = new Redis();
        // $connect     = self::$redis->connect(self::$config['host'], self::$config['port'], self::$config['timeout']);
{'fraction_non_alphanumeric': 0.1533442088091354, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 2.2354881266490767, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5118889', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1415, 'n_words': 355}