<?php
   include "User.php";
   use \User as User;

   //Connecting to Redis server on localhost 
   function connect(){
      include 'config.php';
      $redis = new Redis(); 
      $redis->connect('127.0.0.1', 6379); 
      $redis->auth("$REDIS_PASS");
      return $redis;
   }
   function redis_get($key){
      $redis = connect();
      return json_decode($redis->get($key));
   }

   function redis_get_user($key) {
      $redis = connect();
      $data = json_decode($redis->get($key), true);
      if ($data && gettype($data) == "array") {
         $user = new User();
         $user->init_from_array($data);

         #foreach ($data as $key => $value) $user->{$key} = $value;
         #if (isset($data->password)) $user->set_password($data->password);
         #$user = new User($data->username, $data->first_name, $data->last_name, $data->email, $data->password, $data->organization);
         return $user;
      } else {
         return null;
      }
   }

   function redis_set($key, $data, $timeout=null){
      $redis = connect();
      $redis->set($key, json_encode($data), $timeout);
   }

   function redis_inc_ipdata($ip, $attr, $get=false){
      $count = redis_get($ip);
      if ($count){
         if (isset($count->$attr))  $count->$attr = $count->$attr+1;
         else  $count->$attr = 1;
      }else $count = (object)[$attr=>1];

      if (!$get) redis_set($ip, $count, 3600);
      return $count->$attr;
   }

   function redis_delete($key){
      $redis = connect();
      $redis->del($key);
   }
