• 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

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

No result using makeStyles Material UI in react 18

Problem with fetching data from database in Laravel

Laravel s3 upload file with metadata using pre-signed url

Log file is not being written in Laravel 5.5

Get WooCommerce product variation attribute terms in admin products general box

args[max_input] woocommerce if statement confused

Yii2: How to download backup files using spanjeta/yii2-backup?

How to redirect to another page after n seconds in wordpress without using javascript?

CSS file not imported in laravel blade view

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

PHP, how to convert Int value to Week days

Merge column values from two arrays to form an indexed array of associative arrays

PHP DOTENV unable to load env vars

PHP and WebView - Cookie doesn't are the same

About Contact Privacy policy Terms and conditions