• 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

PHP array, move keys and values to new array, but mix it up

Laravel update hasMany relationship using saveMany

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

best way to store error messages in Laravel (session or variable)

PHP: Print caught exception like Xdebug

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

Batch request Google Calendar php API

php - add comma thousands separator but remove trailing zeros

Add record for each array elements if missing in table

How to implement placeholder in a php file for moodle plugin?

Calculating Median of an array in PHP

Select option from dropdown menu with PHP and mySql

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

args[max_input] woocommerce if statement confused

About Contact Privacy policy Terms and conditions