/** */ public function clear() { try { $res = $this->_predis->keys(addcslashes(strval($this->_params['prefix']), '?*') . '*'); /* Before 2.0, KEYS returns a space-delimited string. */ if (is_string($res)) { $res = explode(' ', $res); } $this->_predis->del($res); } catch (Exception $e) { } }
function redis_session_destroy($id) { global $redisServer, $redisTargetPrefix; $redisConnection = new \Predis\Client($redisServer); $redisConnection->del($redisTargetPrefix . $id); $unpacked = $redisConnection->keys($redisTargetPrefix . $id . ":*"); foreach ($unpacked as $unp) { $redisConnection->del($unp); } }
// if(!$redis->exists("email_" . $hash)){ // mail($Request->email, "Red Ventures - Sphero Registration", "<p>Thanks for registering, " . $Request->firstName .".<br /><br />Your API key is " . $hash . " and the docs to how to send the shpero commands is located <a href='sphero-api.hopto.org/docs' target='_blank'>here</a>. Have fun!</p>"); // $redis->set("email_" . $hash, true); // } // return key return json_encode(array("type" => "success", "key" => $hash)); } catch (Exception $E) { return array("type" => "error", "message" => $E->getMessage()); } }); $app->get('/getInfo', function () { try { // spin up redis $redis = new Predis\Client(); // register the user $RedisData = $redis->keys("*"); $dataArray = []; // return key foreach ($RedisData as $key) { if (strlen($key) != 32) { continue; } $jsonData = $redis->get($key); if (!empty($jsonData)) { $dataArray[$key] = json_decode($jsonData); } } echo "<pre>" . print_r($dataArray, true) . "</pre>"; return; } catch (Exception $E) { return array("type" => "error", "message" => $E->getMessage());
/* * This file is part of the Predis package. * * (c) Daniele Alessandri <*****@*****.**> * * For the full copyright and license info, please view the LICENSE * file that was distributed with this source code. */ require 'SharedConfigurations.php'; // Predis ships with a KeyPrefixProcessor class that is used to transparently // prefix each key before sending commands to Redis, even for complex commands // such as SORT, ZUNIONSTORE and ZINTERSTORE. Key prefixes are useful to create // user-level namespaces for you keyspace, thus eliminating the need for separate // logical databases. $client = new Predis\Client($single_server, array('prefix' => 'nrk:')); $client->mset(array('foo' => 'bar', 'lol' => 'wut')); var_dump($client->mget('foo', 'lol')); /* array(2) { [0]=> string(3) "bar" [1]=> string(3) "wut" } */ var_dump($client->keys('*')); /* array(2) { [0]=> string(7) "nrk:foo" [1]=> string(7) "nrk:lol" } */
<?php /* * This file is part of the Predis package. * * (c) Daniele Alessandri <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require __DIR__ . '/shared.php'; // Predis can prefix keys found in commands arguments before sending commands to // Redis, even for complex commands such as SORT, ZUNIONSTORE and ZINTERSTORE. // Prefixing keys can be useful to create user-level namespaces for you keyspace // thus reducing the need for separate logical databases in certain scenarios. $client = new Predis\Client($single_server, array('prefix' => 'nrk:')); $client->mset(array('foo' => 'bar', 'lol' => 'wut')); var_export($client->mget('foo', 'lol')); /* array ( 0 => 'bar', 1 => 'wut', ) */ var_export($client->keys('*')); /* array ( 0 => 'nrk:foo', 1 => 'nrk:lol', ) */
<div class="col-md-1"></div> </div> <div class="row"> <div class="col-md-1"></div> <div class="col-md-10"> <table class="table"> <tr> <th>Bucket</th> <th>File Name</th> <th>File type</th> <th>File size</th> <th>File</th> <th>Place</th> </tr> <?php $arList = $redis->keys("*"); //foreach($arList as $num => $key){ foreach ($lines as $key) { if ($redis->exists($key)) { // redis exsist $splitKey = preg_split("/@#@/", $key); $filedata = $redis->get($key); $bucket = $splitKey[4]; $filename = $splitKey[0]; $filetype = $splitKey[1]; $filesize = $splitKey[2]; echo '<tr>'; echo '<td>' . $bucket . '</td>'; echo '<td>' . $filename . '</td>'; echo '<td>' . $filetype . '</td>'; echo '<td>' . $filesize . '</td>';
$redis = new Predis\Client(); /* $redis = new Predis\Client(array( "scheme" => "tcp", "host" => "127.0.0.1", "port" => 6379)); */ // print "Successfully connected to Redis\n"; } catch (Exception $e) { header('HTTP/1.0 500 stupid DB'); print "Couldn't connected to Redis\n"; print $e->getMessage(); print "\n"; } if ($stage == "two") { $listofkeys = $redis->keys('*'); $inclvals = filter_input(INPUT_POST, 'inclvals'); if ($inclvals == "false") { header('MIME-Version: 1.0'); header("Content-Type: application/json"); $tmp = json_encode($listofkeys); $jout = str_replace('\\/', '/', $tmp); print $jout; } else { for ($i = 0; $i != count($listofkeys); $i++) { $listofvals[$i]->key = $listofkeys[$i]; $listofvals[$i]->vals = $redis->hgetall($listofkeys[$i]); // print "<p>$i</p>"; } $tmp = json_encode($listofvals); $jout = str_replace('\\/', '/', $tmp);
<?php //ini_set('session.serialize_handler', 'wddx'); require_once __DIR__ . '/../redis-session.php'; $redis = new Predis\Client(); array_map(function ($key) use(&$redis) { //var_dump($redis->get($key)); $redis->del($key); }, $redis->keys("session:php:*")); RedisSession::start(); $_SESSION['test'] = "ohai"; $_SESSION['md'] = array('test2' => array('multidimensional' => 'array')); $_SESSION['more'] = new stdClass();