• 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.1 how to use {{ old('') }} helper on blade file for radio inputs

Nginx disallowing execution of PHP in uploads directory with Magento

Get image type from base64 encoded src string

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Move a child array to parent array and change parent/child name

Object of class stdClass could not be converted to string error

OAuth2 Token PHP

PHP, how to convert Int value to Week days

Open a popup box after receiving result from ajax

args[max_input] woocommerce if statement confused

OctoberCMS / Anonymous Global Scope

About Contact Privacy policy Terms and conditions