• 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

Coinpayments create_transaction "ERROR: Invalid command!"

Object of class stdClass could not be converted to string error

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

PHP Include for HTML?

Artisan, creating tables in database

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

possible options to create pdf file using html elements to generate invoice in php and codeigniter

How to modify CSS in a specific page of the WP admin dashboard (backend)

Statement that checks whether a URL contains a particular path?

Show Custom Data in Woocommerce Order Details Admin Area

Call to a member function givePermissionTo() on null

CodeIgniter extend CI_URI undefined method

Use Python plotly chart in PHP

Nginx RTMP not recording

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

About Contact Privacy policy Terms and conditions