<?php require __DIR__ . '/lib/RedisServer/RedisServer.php'; $conn = new RedisServer(); //$conn->Set('foo', 'bar'); //$conn->Set('foo2', 'bar2'); //$conn->Set('foo3', 'bar3'); //$conn->Set('foo4', 'bar4'); //echo $conn->Get('foo'); //print_r($conn->Keys('*')); $img = base64_encode(file_get_contents('/tmp/img.jpg')); echo $conn->Set('testeimg', $img);
<?php include 'redisserver/RedisServer.php'; include 'config.php'; $redis = new RedisServer(); $redis->connect($redisConfig['host'], $redisConfig['port']); $result = $redis->send_command('set', 'lua_queue_count', '10'); echo 'success';
<?php /** * PHP Media Server configuration file */ require __DIR__ . '/config.php'; require __DIR__ . '/lib/RedisServer/RedisServer.php'; // Valida URI recebida $out = array(); preg_match_all("/\\/img\\/([c||b])\\/([0-9]+)x([0-9]+)\\/([A-Za-z0-9]+).jpg/", PHPMS_REQUEST_URI, $out); // Parse dos parâmetros list($color, $width, $height, $hash) = array($out[1][0], $out[2][0], $out[3][0], $out[4][0]); $redis = new RedisServer(); $redis_img = $redis->Get($hash); if ($redis_img) { $x = $width; $y = $height; $image_dest = imagecreatetruecolor($width, $height); $image_orig = imagecreatefromstring(base64_decode($redis_img)); // Caso seja zerado o width e height, não precisa cropar if ($width > 0 && $height > 0) { imagecopyresampled($image_dest, $image_orig, 0, 0, 0, 0, $x + 1, $y + 1, imagesx($image_orig), imagesy($image_orig)); } else { $image_dest = $image_orig; } // Aplicando filtro de cor if ($color == 'b') { // Preto e branco imagefilter($image_dest, IMG_FILTER_GRAYSCALE); } //salvando o conteúdo da imagem em variável
<?php include 'redisserver/RedisServer.php'; include 'config.php'; $redis = new RedisServer(); $redis->connect($redisConfig['host'], $redisConfig['port']); $stock = $redis->send_command('get', 'lua_queue_stock'); if ($stock && $stock > 0) { $redis->send_command('decr', 'lua_queue_stock'); $result = $redis->send_command('get', 'lua_queue_count'); echo json_encode(['code' => 1, 'message' => 'success', 'stock' => intval($stock) - 1, 'queue' => intval($result), 'environment' => 'Php']); } else { echo json_encode(['code' => -2, 'message' => 'failed. out of stock.', 'stock' => intval($stock), 'environment' => 'Php']); }
array_shift($this->params); $method = array_shift($this->params); $method = preg_replace('/[^a-z_]/i', '', $method); $handler = "handle" . ucfirst($method); if (method_exists($this, $handler)) { $this->{$handler}(); } else { $this->error("Unknown method {$method}"); } } } $api = new RestAPI(); $api->dispatch(); if (!empty($CONF['redis_host'])) { if (empty($redis_handler)) { $redis_handler = new RedisServer($CONF['redis_host'], $CONF['redis_port']); } $redis_handler->Select($CONF['redis_db'] + 2); $bits = array(); $bits[] = $_GET['key']; $bits[] = getRemoteIP(); if (strlen($_SERVER['HTTP_REFERER']) > 2) { $ref = @parse_url($_SERVER['HTTP_REFERER']); $bits[] = $ref['host']; } else { $bits[] = ''; } if (strlen($_SERVER['HTTP_USER_AGENT']) > 2) { $bits[] = preg_replace('/[^\\w]+/', '_', $_SERVER['HTTP_USER_AGENT']); } $identy = implode('|', $bits);