• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Redis Command To Sort Keys

javascriptphpsortingredis


PHP Snippet 1:

EVAL "local keys = redis.call('KEYS','post:*');
      if (table.getn(keys) == 0) then return {} end;
      table.sort(keys);
      return redis.call('MGET',unpack(keys));"

PHP Snippet 2:

// a scoreless sorted set can be used as an index
SET post:1500 <value>
ZADD posts_index 0 post:1500

// Whenever you need a sorted (range) of items, you first check the index 
ZRANGE posts_index - + BYLEX 
ZRANGE posts_index [posts:1000 (posts:2000 BYLEX 

Related Snippets

Check If array is null or not in php

Laravel 8 Multiple Relationships for Factory

Currently Using CodeIgniter Framework i have an Error

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

Using array_intersect on a multi-dimensional array

How to edit Records using CodeIgniter

Can we define variables in `.tpl` files?

Magento 2 - How to add new block to admin panel in product page?

How to create a scheduler application in php

Laravel: HTML in notification

Laravel Mix Uncaught ReferenceError: $ is not defined

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

browsersync doesn't work with XAMPP

how to insert data into select2 search input after scan using qrcode

About Contact Privacy policy Terms and conditions