What is redis server ?

Redis is an open source under BSD licensed, in-memory data structure store, used as a database, cache and message broker. Redis supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

It is written in ANSI C and … Read more

Installation step of Redis?

You need to download the phpredis from redis website https://redis.io/download Once you’ve downloaded it, extract the files to phpredis directory. On Ubuntu, install the following extension.

Installation step of Redis
cd phpredis
sudo phpize
sudo ./configure
sudo make
sudo make install

Add extension in php.ini.

Add Module
extension = redis.so
Read more

Redis PHP Save/Retrive Data ?

Here is the simple step to connect to Redis server on localhost and retrieve data.

Redis PHP String – Save/Retrive
<?php

//Connecting to Redis server
$redis = new Redis();
$redis-connect(‘127.0.0.1’, 8001);
echo “Connected to Redis server”;
//set the data
$redis-set(“name”, “Kiran”);
// Get the stored data
echo “Name

Read more

Redis PHP Save/Retrive List of records ?

Here is the simple step to connect to Redis server on localhost and retrieve list of records.

Redis PHP Multiple records – Save/Retrive
<?php

//Connecting to Redis server
$redis = new Redis();
$redis-connect(‘127.0.0.1’, 8001);
echo “Connected to Redis server !”;
//set the data
$redis-lpush(“students-list”, “Arun”);
$redis-lpush(“students-list”, “Sarath”);

Read more

Laravel : Pagination with cache

Here is the code to Laravel Pagination with cache

Laravel : Pagination with cache
<?php

$currentPage = isset($_GET[‘page’]) ? (int)$_GET[‘page’] : 1;
$students = Cache::remember(‘students-‘ . $currentPage, 10, function(){
return DB::table(‘students’)-orderBy(‘updated_at’, ‘desc’)-paginate(10);
});

?>
Read more