• 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

Natural ORDER in Laravel Eloquent ORM

Dropdown with current value from Mysql

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

How to get unique slug to same post-title for other time too?

Attempted to call an undefined method named "get" of class "MailController"

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

How to add a sidebar to Woocommerce Shop Page?

How to execute sql code based on fetch array

advanced custom fields wordpress custom class

PHP array slice from position + attempt to return fixed number of items

Laravel update hasMany relationship using saveMany

Why does array_map() with null as callback create an "array of arrays"?

Laravel Sanctum CSRF not authenticating

How in Laravel run JavaScript code stored in php variable?

About Contact Privacy policy Terms and conditions