Skip to main content

A module that combines the use of redis in-built data types to build a unique queue for processing and expiry.

Project description

redis-unique-queue

A module that combines the use of redis in-built data types to build a unique queue for processing and expiry.

Usage

Items are put on the queue with an optional key. A duplicate key cannot be added until either: - the previous key that was added has been fully processed. - expiry_in_seconds have passed.

The unique queue creates 3 datastructures to ensure the keys are unique. To ensure the keys don’t linger after usage, all commands reset the ttl on the datastructures. Examples ——– .. code-block:: python

import time

import redis

import ruqueue

expiry_in_seconds = 1 conn = redis.Redis() uqueue = ruqueue.Queue(redis_conn=conn, expiry_in_seconds=expiry_in_seconds) uqueue.put(100) print(“Expected size 1:”, uqueue.qsize())

uqueue.put(100) # not added again print(“Expected size 1:”, uqueue.qsize())

uqueue.put(200) # not added again print(“Expected size 2:”, uqueue.qsize())

print(“Expected item 100:”, uqueue.get()) # get an item

time.sleep(expiry_in_seconds) # go past expiry seconds to test

# item 100 has expired

print(“Items that expired:”, uqueue.clear_expired()) # [100] -> a list of items that expires

print(“Expected size 1:”, uqueue.qsize())

print(“Expected item 200:”, uqueue.get()) # we have finished handling 200

uqueue.task_done(200) print(“Expected size 0:”, uqueue.qsize())

print(“Expected item None:”, uqueue.get())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis_unique_queue-0.0.4.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redis_unique_queue-0.0.4-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file redis_unique_queue-0.0.4.tar.gz.

File metadata

  • Download URL: redis_unique_queue-0.0.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for redis_unique_queue-0.0.4.tar.gz
Algorithm Hash digest
SHA256 de9e90ca022507a7c56fbe6a2a86dd0bb35647938c3ce50c6fa157e1816563fd
MD5 b5eeaba2b99bfca0058555560f717399
BLAKE2b-256 5ffd621376e9ce4fb98579bc5c2330fc7c07183c2c6ddd187376d76ee3803eac

See more details on using hashes here.

File details

Details for the file redis_unique_queue-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for redis_unique_queue-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4a4cf87a7e585fc5c7d77f1061da9e03b993a9d363dca719ff0105bf5ea54f4a
MD5 17a5baeceab554b89e11109b4c7c2c70
BLAKE2b-256 65f9f43d742dbe21dab1c2d342dac59933e9c19529b69a3275c235a65e2a74e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page