• 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

Currently Using CodeIgniter Framework i have an Error

Select option menu read from database and use it's values

how to sort by a custom appended relation to model

PHP sort array of objects by two properties

I want to store data in new index as per my key in php [duplicate]

loop through an anchor id

AJAX call fails with SyntaxError: Unexpected end of JSON input

Laravel database insert with combining array and string

Laravel PHP: multiple project run at the same time [closed]

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

Appending data to an anchor tag

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

Shopify password update using Shopify API

Show rotation of tweets using current day of month

Where do I need to place a hook for phpunit?

About Contact Privacy policy Terms and conditions