<commit_before><?php
// CACHE class (Based on file From ProjectGazelle)
// See: https://github.com/WhatCD/Gazelle/blob/master/classes/cache.class.php

class CACHE extends Memcache{
	private $cacheReadTimes = 0;
	private $cacheWriteTimes = 0;
  private $keyHits = [
    'read' => [],
    'write' => [],
  ];

	function __construct($host = 'localhost', $port = 11211) {
		$success = $this->connect($host, $port); // Connect to memcache
		if (!$success) {
      throw new RuntimeException('Can\'t connact to Memcached');
		}
	}

	function lock($Key){
		$this->cache_value('lock_'.$Key, 'true', 3600);
	}
	
	function unlock($Key) {
		$this->delete('lock_'.$Key);
	}

  function check_lock($Key) {
    return $this->get_value('lock_'.$Key) ? true : false;
  }
	
	function cache_value($Key, $Value, $Duration = 3600){
		$this->set($Key, $Value, 0, $Duration);

		$this->cacheWriteTimes++;
		$this->keyHits['write'][$Key] = !isset($this->keyHits['write'][$Key]) ? 1 : $this->keyHits['write'][$Key] + 1;
	}

	function get_value($Key) {
		$res = $this->get($Key);

    if ($res == false) return false;
<commit_msg>replace Memcache with Memcached<commit_after><?php
// See: https://github.com/WhatCD/Gazelle/blob/master/classes/cache.class.php

class CACHE extends Memcached {
	private $cacheReadTimes = 0;
	private $cacheWriteTimes = 0;
  private $keyHits = [
    'read' => [],
    'write' => [],
  ];

	function lock($Key){
		$this->cache_value('lock_'.$Key, 'true', 3600);
	}
	
	function unlock($Key) {
		$this->delete('lock_'.$Key);
	}

  function check_lock($Key) {
    return $this->get_value('lock_'.$Key) ? true : false;
  }
	
	function cache_value($Key, $Value, $Duration = 3600){
		$this->set($Key, $Value, $Duration);

		$this->cacheWriteTimes++;
		$this->keyHits['write'][$Key] = !isset($this->keyHits['write'][$Key]) ? 1 : $this->keyHits['write'][$Key] + 1;
	}

	function get_value($Key) {
		$res = $this->get($Key);

    if ($res == false) return false;

{'fraction_non_alphanumeric': 0.20633299284984677, 'fraction_numerical': 0.015321756894790603, 'mean_word_length': 4.128272251308901, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 2, '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': '7613436', 'n_tokens_mistral': 757, 'n_tokens_neox': 706, 'n_words': 138}