• 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 Download MP3 files from directory on server

Laravel Mix Uncaught ReferenceError: $ is not defined

Refresh specific HTML content that retrieves data from MySQL

Jquery DataTables: Data not displaying in table via Ajax

Filter array by skipping every nth element from the end

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

How to check user Permissions using Custom Middleware in Laravel

Form repeater send wrong data with last element in Laravel

How to create laravel storage symbolic link for production or sub domain system?

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

retrieve data from database using session

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Not able to access model in the controller mautic

PHP Print to Network Printer

backup files to google drive using PHP

About Contact Privacy policy Terms and conditions