• 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

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

How to use $this->session->set_userdata in codeigniter

Laravel MSSQL Server Connection not working

Laravel/docker-compose/redis - Class 'Redis' not found

Limit login attempts in Laravel 5.7

PHPExcel_IOFactory::createWriter causes wrong behaviour

Access relation of pivot table in Laravel

Call authenticate manually in router middleware

Laravel unique validation on multiple columns

Printing more than one array using print_r or any other function in php

Check if my GET request has Header: Token

WHM Enabling mod_rewrite

Array to string conversion

How to unlink image from folder?

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

About Contact Privacy policy Terms and conditions