• 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

Cannot pass null argument when using type hinting

PHP sort array of objects by two properties

Creating Combinations of Elements

Testing subscription renewals on Stripe

Call to a member function givePermissionTo() on null

Symfony Error: "An exception has been thrown during the rendering of a template"

jQuery Ajax Post with data

Inserting data into SQL Server Db An Invalid direction was specified

Laravel after login Two factor not working

How do I pass the dynamic output of a php variable or php function to a CSS variable?

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Doctrine 2 mapping referencing unique key

Only on Firefox "Loading failed for the <script> with source"

Use same method for inertia response and json response Laravel Jetstream

About Contact Privacy policy Terms and conditions