• 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

send email using gmail-api and google-api-php-client

Sum column values from multiple arrays

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

Warning: A non-numeric value encountered

How to redirect to another page and call a Function there on Angular ng-click

How to create a cookie to store the timestamp of when a page is first loaded with php

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

How to show selected value using javascript in laravel

Dynamic table in HTML using MySQL and php

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

zsh: command not found: php

How to add automatically collapse/expand in content wordpress (single.php)?

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Laravel Route issues with Route order in web.php

About Contact Privacy policy Terms and conditions