• 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

How to run a shell as root from php (apache)

How to test a php login connected to a mysql db through xampp?

Why isn't my PHP exception working?

Laravel: HTML in notification

Make Calculator - When Button clicked the No shows in Textbox.

Nginx RTMP not recording

PHP Array split string and Integers

How to break out of a foreach once a condition is met?

Symfony Error: "An exception has been thrown during the rendering of a template"

Creating a config file in PHP

file_get_contents() without "Http" to access external URL [closed]

Laravel whole batch is cancelled if one Job fails

Xdebug can't connect back to Docker host

PHPExcel export HTML table to xlsx

How to insert data from multiple select dropdown values into database?

About Contact Privacy policy Terms and conditions