• 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

Laravel with App Engine Standard Class 'FacadeIgnitionIgnitionServiceProvider' not found

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

Sum array values of a column within each column of an array with 3 levels

Session timeout in Yii2

Cannot pass null argument when using type hinting

How to get variable from JavaScript to PHP [duplicate]

Required field only if another field has a value, must be empty otherwise

Send same name multiple checkbox values via ajax

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

PHP returning an error message and false

Detect emoticons in string

Comma separated list from array with "and" before last element

how to remove white space in select 2

PHP/HTML: Creating A SubMenu

woocommerce_wp_select options array from product attribute terms

About Contact Privacy policy Terms and conditions