• 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

Star rating with half star support

How do I truncate a decimal in PHP?

zsh: command not found: php

Unable to guess the mime type as no guessers are available Laravel 5.2

Python - Include another Python script

Can't call javascript alert alertify library from PHP

Laravel UUID generation

How to to send mail using gmail in Laravel?

Refresh specific HTML content that retrieves data from MySQL

How to access a var with "-" in PHP [duplicate]

How to insert Google Adsense Code in PHP script?

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

Laravel lang slug in url

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

How to get array values using foreach in laravel

About Contact Privacy policy Terms and conditions