• 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

Star and Half Star Rating in Laravel

Results page in other window

How to update array value in Laravel

Google Calendar API batch request PHP

How to upload mpdf file after generating to s3 bucket in php

PHPExcel_IOFactory::createWriter causes wrong behaviour

How to show selected value using javascript in laravel

Why does using salted hash on python and php give me different results?

sort() not affecting original array while inside foreach loop

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

How do I remove this delivery notification from here?

Login if user is active using Laravel Breeze

Symfony Mercure "Failed to send an update"

How to get Laravel's CSRF Token from Another Website?

HTML and PHP in one file

About Contact Privacy policy Terms and conditions