• 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

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

Assign output of PHP function to a variable

PHPExcel How to set conditional formatting to change cell background color based on cells values

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Split array into 4-element chunks then implode into strings

laravel sanctum Route [login] not defined

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

Wordpress 'post_type_link' hides permalink

How to get company posts from LinkedIn via API?

Laravel 8 Multiple Relationships for Factory

Star rating with half star support

Select option menu read from database and use it's values

Get data from accuweather api url

How avoid Moved Permanently The document has moved here

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

About Contact Privacy policy Terms and conditions