• 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

Normalize DateInterval in PHP

get folder directory from input type file - PHP

MISSING UPDATES FOR: MEDIA Drupal 9

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Error converting docx to pdf using Unoconv

PhP how to calculate moments with variables rows

Laravel php artisan serve to mimic HTTPS

Testing subscription renewals on Stripe

Split comma separated value from table column into rows using mysql?

How to average columns of data from multiple, flat arrays?

Shortcode or PHP inside a shortcode in Wordpress

Confirm Leave on External Links in Wordpress

Laravel Unknown Column 'updated_at'

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

Call to undefined function openssl_decrypt

About Contact Privacy policy Terms and conditions