• 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 Unknown Column 'updated_at'

MySQL - Connection failed: No route to host

How to get the ID of the link in another page in php

What is the function of the (new Date()).getTime() in PHP?

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

PHPS source file - 403 Forbidden You don't have permission to access this resource

Execute only one time and then wait set period of time before executing again

Convert date and time to Jalali in Laravel

Remove product downloads section in woocommerce email notifications

GRPC installed successfully on ubuntu but php is looking for it in another folder

Combine multiple columns into an array as one of the key in a results set

PHP mail sending empty mails

How to send upload image through email

Facebook PHP SDK - will not logout properly

Parsing JSON File to array in PHP

About Contact Privacy policy Terms and conditions