<commit_before><?php
/**
 * Copyright (c) 2009 JadeIT cc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * @license http://www.eclipse.org/legal/epl-v10.html
 * @package Controllers
 *
 * Contributors:
 * @author <NAME> (JadeIT cc) - initial API and implementation
 */
class Value extends TableCtl {
	private static $cache = array();
	function action_test() {
		self::set('test', 'on');
		var_dump(self::get('test'));
		self::set('test', 'off');
		var_dump(self::get('test'));
		die('Value::action_test');
	}
	
	public static function get($name, $default = null) {
		$toret = $default;
		//The only call allowed without BACKEND_INSTALLED = true, is to get the value for BACKEND_INSTALLED
		if (!defined('BACKEND_INSTALLED') || BACKEND_INSTALLED) {
			if (isset(self::$cache[$name])) {
				$toret = self::$cache[$name];
			} else {
				$toret = Value::retrieve($name);
				if ($toret) {
					$toret = !empty($toret['value']) ? $toret['value'] : $default;
				} else if (!is_null($default)) {
					$toret = $default;
					Value::set($name, $default);
				}
			}
		}
		self::$cache[$name] = $toret;
		return $toret;
	}
	
	public static function set($name, $new_value) {
		$new_value = base64_encode(serialize($new_value));

		$value = new ValueObj();
		$data = array(
			'name' => $name,<commit_msg>Value::set leaves serialization to DBObject<commit_after><?php
/**
 * Copyright (c) 2009 JadeIT cc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * @license http://www.eclipse.org/legal/epl-v10.html
 * @package Controllers
 *
 * Contributors:
 * @author <NAME> (JadeIT cc) - initial API and implementation
 */
class Value extends TableCtl {
	private static $cache = array();
	function action_test() {
		self::set('test', 'on');
		var_dump(self::get('test'));
		self::set('test', 'off');
		var_dump(self::get('test'));
		die('Value::action_test');
	}
	
	public static function get($name, $default = null) {
		$toret = $default;
		//The only call allowed without BACKEND_INSTALLED = true, is to get the value for BACKEND_INSTALLED
		if (!defined('BACKEND_INSTALLED') || BACKEND_INSTALLED) {
			if (isset(self::$cache[$name])) {
				$toret = self::$cache[$name];
			} else {
				$toret = Value::retrieve($name);
				if ($toret) {
					$toret = !empty($toret['value']) ? $toret['value'] : $default;
				} else if (!is_null($default)) {
					$toret = $default;
					Value::set($name, $default);
				}
			}
		}
		self::$cache[$name] = $toret;
		return $toret;
	}
	
	public static function set($name, $new_value) {
		//$new_value = base64_encode(serialize($new_value));

		$value = new ValueObj();
		$data = array(
			'name' => $name,
{'fraction_non_alphanumeric': 0.16428084526244036, 'fraction_numerical': 0.006816632583503749, 'mean_word_length': 4.12216404886562, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '781359', 'n_tokens_mistral': 1090, 'n_tokens_neox': 961, 'n_words': 259}