| //Connecting to Redis server on localhost |
| $redis->connect('127.0.0.1', 6379); |
| $redis->auth("$REDIS_PASS"); |
| function redis_get($key){ |
| return json_decode($redis->get($key)); |
| function redis_get_user($key) { |
| $data = json_decode($redis->get($key)); |
| if ($data && gettype($data) == "object") { |
| 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); |
| function redis_set($key, $data, $timeout=null){ |
| $redis->set($key, json_encode($data), $timeout); |
| function redis_inc_ipdata($ip, $attr, $get=false){ |
| if (isset($count->$attr)) $count->$attr = $count->$attr+1; |
| }else $count = (object)[$attr=>1]; |
| if (!$get) redis_set($ip, $count, 3600); |
| function redis_delete($key){ |