Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit cc00694

Browse files
author
Gab
committed
Change default order to descending
1 parent 2f1a067 commit cc00694

17 files changed

+39
-40
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ Output is similar to [ZADD](https://redis.io/commands/zadd)
4646
## `pop`: Pop an item from the queue
4747

4848
### Usage
49-
`pop my_list [(string) asc/desc (default: 'asc')] [(int) numer_of_items (default: 1')]`
49+
`pop my_list [(string) asc/desc (default: 'desc')] [(int) numer_of_items (default: 1')]`
5050

5151
### Examples
5252

5353
```
54-
-- Pop 1 item ordered by ascending priority
54+
-- Pop 1 item ordered by descending priority
5555
pop my_super_list
5656
57-
-- Pop 1 item ordered by descending priority
58-
pop my_super_list desc
57+
-- Pop 1 item ordered by ascending priority
58+
pop my_super_list asc
5959
60-
-- Pop 5 items ordered by ascending priority
61-
pop my_super_list asc 5
60+
-- Pop 5 items ordered by descending priority
61+
pop my_super_list desc 5
6262
```
6363

6464
### Return

clients/php/lib/Queue.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public function push(string $item, int $priority = null): int
8080
* popOne function.
8181
*
8282
* @access public
83-
* @param string $orderBy (default: 'asc')
83+
* @param string $orderBy (default: 'desc')
8484
* @return void
8585
*/
86-
public function popOne(string $orderBy = 'asc')
86+
public function popOne(string $orderBy = 'desc')
8787
{
8888
// Get item
8989
$item = $this->popMany($orderBy, 1);
@@ -101,10 +101,10 @@ public function popOne(string $orderBy = 'asc')
101101
* Alias to popOne();
102102
*
103103
* @access public
104-
* @param string $orderBy (default: 'asc')
104+
* @param string $orderBy (default: 'desc')
105105
* @return misc
106106
*/
107-
public function pop(string $orderBy = 'asc')
107+
public function pop(string $orderBy = 'desc')
108108
{
109109
return $this->popOne($orderBy);
110110
}
@@ -113,11 +113,11 @@ public function pop(string $orderBy = 'asc')
113113
* popMany function.
114114
*
115115
* @access public
116-
* @param string $orderBy (default: 'asc')
116+
* @param string $orderBy (default: 'desc')
117117
* @param int $numberOfItems (default: 1)
118118
* @return void
119119
*/
120-
public function popMany(string $orderBy = 'asc', int $numberOfItems = 1)
120+
public function popMany(string $orderBy = 'desc', int $numberOfItems = 1)
121121
{
122122
// Set args
123123
$this->prepareArgs('pop', [$orderBy, $numberOfItems]);
@@ -129,11 +129,11 @@ public function popMany(string $orderBy = 'asc', int $numberOfItems = 1)
129129
* peek function.
130130
*
131131
* @access public
132-
* @param string $orderBy (default: 'asc')
132+
* @param string $orderBy (default: 'desc')
133133
* @param int $numberOfItems (default: 1)
134134
* @return misc
135135
*/
136-
public function peek(string $orderBy = 'asc', int $numberOfItems = 1)
136+
public function peek(string $orderBy = 'desc', int $numberOfItems = 1)
137137
{
138138
// Set args
139139
$this->prepareArgs('peek', [$orderBy, $numberOfItems]);

clients/php/tests/peek.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
echo json_encode($res)."\n";
2020

2121
// Run
22-
echo "* peek (one, descending):\n";
23-
$res = $q->peek('desc');
22+
echo "* peek (one, ascending):\n";
23+
$res = $q->peek('asc');
2424
echo json_encode($res)."\n";
2525

2626
// Run
2727
echo "* peek (many):\n";
28-
$res = $q->peek('asc', MULTIPLE_ITEMS_COUNT);
28+
$res = $q->peek('desc', MULTIPLE_ITEMS_COUNT);
2929
echo json_encode($res)."\n";

clients/php/tests/pop.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
echo $res."\n";
2020

2121
// Run
22-
echo "* pop (one, descending):\n";
23-
$res = $q->popOne('desc');
22+
echo "* pop (one, ascending):\n";
23+
$res = $q->popOne('asc');
2424
echo $res."\n";
2525

2626
// Run
2727
echo "* pop (many):\n";
28-
$res = $q->popMany('asc', MULTIPLE_ITEMS_COUNT);
28+
$res = $q->popMany('desc', MULTIPLE_ITEMS_COUNT);
2929
echo json_encode($res)."\n";

clients/php/utils/const.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
define('QUEUE_NAME', 'sample_queue');
66
define('ITEM_NAME', 'sample_item');
77
define('MULTIPLE_ITEMS_COUNT', 5);
8-
define('ORDER_BY', 'asc');
98
define('PRIORITY', 1);

clients/python/lib/RpqQueue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ def push(self, item, priority = None):
2222
return self.queue(args = args)
2323

2424
# Pop an item / some items
25-
def pop(self, orderBy = 'asc', numberOfItems = 1):
25+
def pop(self, orderBy = 'desc', numberOfItems = 1):
2626
return self.queue(args = ['pop', self.queueName, orderBy, numberOfItems])
2727

2828
# Peek in a queue
29-
def peek(self, orderBy = 'asc', numberOfItems = 1):
29+
def peek(self, orderBy = 'desc', numberOfItems = 1):
3030
return self.queue(args = ['peek', self.queueName, orderBy, numberOfItems])
3131

3232
# Get queue size

clients/python/peek.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def listItems(items):
3636
items = RpqQueue.peek()
3737
listItems(items)
3838

39-
print ('* peek (one, descending):')
40-
items = RpqQueue.peek('desc')
39+
print ('* peek (one, ascending):')
40+
items = RpqQueue.peek('asc')
4141
listItems(items)
4242

4343
print ('* peek (many):')
44-
items = RpqQueue.peek('asc', 5)
44+
items = RpqQueue.peek('desc', 5)
4545
listItems(items)

clients/python/pop.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def listItems(items):
3636
items = RpqQueue.pop()
3737
listItems(items)
3838

39-
print ('* pop (one, descending):')
40-
items = RpqQueue.pop('desc')
39+
print ('* pop (one, ascending):')
40+
items = RpqQueue.pop('asc')
4141
listItems(items)
4242

4343
print ('* pop (many):')
44-
items = RpqQueue.pop('asc', 5)
44+
items = RpqQueue.pop('desc', 5)
4545
listItems(items)

src/redis-priority-queue.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- redis-priority-queue
22
-- Author: Gabriel Bordeaux (gabfl)
33
-- Github: https://github.com/gabfl/redis-priority-queue
4-
-- Version: 1.0.1
4+
-- Version: 1.0.2
55
-- (can only be used in 3.2+)
66

77
-- Get mandatory vars
@@ -46,10 +46,10 @@ then
4646
elseif action == 'pop' or action == 'peek' or action == 'list' or action == 'view'
4747
then
4848
-- debug
49-
redis.debug('Pop an item');
49+
redis.debug('Pop/peek items');
5050

5151
-- Define vars
52-
local orderBY = ARGV[3] or 'asc';
52+
local orderBY = ARGV[3] or 'desc';
5353
local itemsCount = ARGV[4] or 1;
5454

5555
-- Sorting vars

tests/count.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source set_vars.sh
44

5-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , count $QUEUE_NAME
5+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , count $QUEUE_NAME

tests/peek.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source set_vars.sh
44

5-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , peek $QUEUE_NAME $ORDER_BY
5+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , peek $QUEUE_NAME $ORDER_BY

tests/peek_multiple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source set_vars.sh
44

5-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , peek $QUEUE_NAME $ORDER_BY $MULTIPLE_ITEMS_COUNT
5+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , peek $QUEUE_NAME $ORDER_BY $MULTIPLE_ITEMS_COUNT

tests/pop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source set_vars.sh
44

5-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , pop $QUEUE_NAME $ORDER_BY
5+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , pop $QUEUE_NAME $ORDER_BY

tests/pop_multiple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source set_vars.sh
44

5-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , pop $QUEUE_NAME $ORDER_BY $MULTIPLE_ITEMS_COUNT
5+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , pop $QUEUE_NAME $ORDER_BY $MULTIPLE_ITEMS_COUNT

tests/push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
source set_vars.sh
44

5-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , push $QUEUE_NAME $ITEM_NAME $PRIORITY
5+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , push $QUEUE_NAME $ITEM_NAME $PRIORITY

tests/push_multiple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ source set_vars.sh
44

55
for i in `seq 1 $MULTIPLE_ITEMS_COUNT`;
66
do
7-
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_AUTH --eval ../src/redis-priority-queue.lua null null , push $QUEUE_NAME $ITEM_NAME"$i" $PRIORITY
7+
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a "$REDIS_AUTH" --eval ../src/redis-priority-queue.lua null null , push $QUEUE_NAME $ITEM_NAME"$i" $PRIORITY
88
done

tests/set_vars.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ REDIS_AUTH=""
1010
QUEUE_NAME="sample_queue"
1111
ITEM_NAME="sample_item"
1212
MULTIPLE_ITEMS_COUNT=5
13-
ORDER_BY="asc"
13+
ORDER_BY="desc"
1414
PRIORITY=1

0 commit comments

Comments
 (0)