• 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 5.5 change unauthenticated login redirect url

Which is faster php date functions or carbon?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

PHP file_get_contents function

PHPExcel export HTML table to xlsx

How to downgrade or install a specific version of Composer?

Nginx RTMP not recording

Php - Sum up the numbers in an array one by one

protect my blog content

WordPress Security Standards want me to escape my html, but how to do it correctly?

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

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

How to use React Router with Laravel?

How can I get new CSRF token in LARAVEL by using ajax

Creating command to backup MySql database in Laravel

About Contact Privacy policy Terms and conditions