• 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

How can i update or reset my password without entering email field in laravel-8?

Laravel get user data with profile

how can I set a session variable in Drupal 8 and get it in a php script?

Display a product custom field only in WooCommerce Admin single orders

Unable to get password for the instance created from AMI

Getting public posts of a random user from Facebook API

Add record for each array elements if missing in table

Generate random username based on full name php

How can I create a Download Page with post php method?

Update Order custom Field value with WooCommerce REST API

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

Add 2 Webcam in one page with WebcamJS

500 Internal Server Error on Ajax request. Not sure the origin of the problem

Sort a multidimensional array by integer inside of a string value which is two levels down

How can I create a Download Page with post php method?

About Contact Privacy policy Terms and conditions