danthegoodman1 / UltraQueue

Distributed pull queue based on Segment's Centrifuge. Zero dependency p2p clustering.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Payload caching #38

Open danthegoodman1 opened 2 years ago

danthegoodman1 commented 2 years ago

Using https://github.com/dgraph-io/ristretto we can have a TTL cache for payloads, up to a certain configured size. Or we can make a custom one ourselves with a btree and a cost counter.

We will need to check this before checking the taskDB if enabled.

The purpose is that up to a configured working set of memory, we can keep the payload in memory since the task should be relatively short lived.

We can make a few rules that determine whether a payload should go in the cache:

  1. It was not delayed (enqueue, nack)
  2. The payload is smaller than some max cached payload size

We need to add configuration for:

  1. Size of the cache in MB (0 disables payload cache)
  2. TTL of the cache

We should still require that an enqueue is committed to the TaskDB before returning the request though