• 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

Change the alert text on add to cart action without selected variation in Woocommerce

Valet, Xdebug after reboot Big Sur not working

Require a class from another class - php

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

browsersync doesn't work with XAMPP

Changing font color in javascript

Form repeater send wrong data with last element in Laravel

How to show selected value using javascript in laravel

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

(Cache::lock()) -> get() -- Under what conditions does it return false?

Getting output of MS stored procedure on php call

How to get monthly wise data in laravel

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

how to redirect the user back to desired URL after login page in PHP?

How can I format this number correctly using PHP?

About Contact Privacy policy Terms and conditions