• 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

protect my blog content

Fetch files from next cloud storage and display in Laravel website

Create a zip file and download it

Issue saving card for customer

How to load Codeigniter 4 lang file into an array variable

Malformed MIME header error in Symfony 5.3

Symfony Mercure "Failed to send an update"

Popup Window and PHP form

PHP each() function replacement

Laravel: HTML in notification

Access denied for user 'homestead'@'localhost' (using password: YES)

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

Show Custom Data in Woocommerce Order Details Admin Area

Confirm Leave on External Links in Wordpress

Laravel 5.2: Unable to locate factory with name [default]

About Contact Privacy policy Terms and conditions