Skip to content

Commit

Permalink
Merge pull request #25 from plivo/VT-5650
Browse files Browse the repository at this point in the history
lua_script_added
  • Loading branch information
abhishekGupta-Plivo authored Aug 8, 2023
2 parents d208676 + 1d082ac commit be90d9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
MINOR RELEASE v1.3.0
- Added function to get queue length

MINOR RELEASE v1.2.0
- Allow interval to be 0.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='SharQ',
version='1.2.0',
version='1.3.0',
url='https://github.com/plivo/sharq',
author='Plivo Team',
author_email='[email protected]',
Expand Down
18 changes: 18 additions & 0 deletions sharq/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,21 @@ def clear_queue(self, queue_type=None, queue_id=None, purge_all=False):
# always delete the job queue list
self._r.delete(job_queue_list)
return response

def get_queue_length(self, queue_type, queue_id):
"""
Return the current length present in redis key of type list
Redis key structure : key_prefix : queue_type : queue_id
"""

# validate all the input
if not is_valid_identifier(queue_type):
raise BadArgumentException('`queue_type` has an invalid value.')

if not is_valid_identifier(queue_id):
raise BadArgumentException('`queue_id` has an invalid value.')

redis_key = self._key_prefix + ':' + queue_type + ':' + queue_id
current_queue_length = self._r.llen(redis_key)
return current_queue_length

0 comments on commit be90d9c

Please sign in to comment.