PHP code example of tsk / simple-redis-dal

1. Go to this page and download the library: Download tsk/simple-redis-dal library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tsk / simple-redis-dal example snippets


$db = new hooli("127.0.0.0", "password");

$db->ping();

$key = "username";
$db->setvalue($key, "MaryPoppins");
 
$username = $db->getvalue($key);

$key = "username";
$db->delete($key);
 
$key = "session_id";
$value = "12345";
$time = 20 // Time is in minutes

$db->cachevalue($key, $value, $time);
 
$key = "session_id";
$time = 1 // Time in minutes

$db->expire($key, $time);

$data = [
    "firstName" => "Mary",
    "lastName" => "Poppins",
    "email" => "[email protected]",
    "location" => "USA, New York"
];
$HashName = '[email protected]';
$db->createhash($HashName, $data);

$HashName = '[email protected]';
$db->checkhash($HashName, "firstName");

$HashName = '[email protected]';
$db->replacehash($HashName, "location", "Nigeria, Lagos");

$HashName = '[email protected]';
$db->inserthash($HashName, "age", 32);

$HashName = '[email protected]';
$db->gethash($HashName);

or using return types
$db->json()->gethash($HashName);

 
$HashName = '[email protected]';
$count = $db->countkeys($HashName);
 
$HashName = '[email protected]';
$key = 'age'; // The value of this key must be an integer
$increaseBy = 4;
$db->increase($HashName, $key); // This method increases the value by one
$db->increaseby($HashName, $key, $increaseBy); // This method increases the value by the specified number 

$List = "users";
$db->insertlist($List, "[email protected]");

$List = "users";
if($db->search_list($List, "[email protected]")){
    echo 'value exists';
}

$List = "users";
$db->countlist($List);

$List = "users";
$db->deletelist($List);

$List = "users";
$db->json()->getlist($List);
 
$List = "users";
$num = 10;
$users = $db->getlistnum($List, $num); // Returns an array

$data = [
    "firstName" => "Mary",
    "lastName" => "Poppins",
    "email" => "[email protected]",
    "location" => "USA, New York"
];
$list = "users";
$userID = "mary123";
$db->inserthashlist($userID, $data, $list);

$list = "users";
echo $db->gethashlist($list);

echo $db->getlistnum($list, $num)

echo $db->gethashlistnum($list, $num)