<?php #lib/90_response.php

/********************************************************************************
 *	Content: Database class                                                     *
 *	Author: Nils Otterpohl                                                      *
 *	Last modification: 03.04.2023                                               *
 *	Version: alpha (object, incomplete, uncommented, untested)                  *
 ********************************************************************************/
 
class KV
{
	private $redis = null;
	private static $instance = null;
	
  /***** Static functions *****/
  
  public static function Get() {
  	if (is_null(self::$instance)) {
  		self::$instance = new self();
  	}
  	return self::$instance->Connection();
  }

  /***** Con-/Destructor *****/
  
  private function __construct() {
  	$this->redis = new Redis();
		$this->redis->connect(REDIS_SOCKET);
		$this->redis->select(1);;
  }
  public function __destruct() {
  	$this->redis->close();
  }
  
  /***** Public functions *****/
  
  public function Connection() {return $this->redis;}
}
