• 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 Model save() & update() Not Saving

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Put content of wordpress page inside div

PHP, how to convert Int value to Week days

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Query Optimization, changing the queries in the loop into a single processing query

ldap is missing from system when installing adldap2 in laravel

oauth-private.key does not exist or is not readable

Adding custom body class to the custom archive pages

Component install error: JInstaller: :Install: File does not exist

PHP/HTML: Creating A SubMenu

Laravel: HTML in notification

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

Elastic Beanstalk with Laravel Envoy

Refresh specific HTML content that retrieves data from MySQL

About Contact Privacy policy Terms and conditions