openresty / openresty/lua-resty-lock

Being able to set an expiration time per key, and not just per dict

Open
#7 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
323
Forks
81
Avg merge
7h 41m
Merged PRs (30d)
2

Description

Currently it's only possible to set an expiration time to the entire dictionary when creating a new instance:

local obj = resty_lock:new("locks_dict", {exptime = 10})

It would be nice to allow setting an expiration time per key too, like:

local obj = resty_lock:new("reports_locks")
obj:lock("test", {exptime = 10})

So that one dictionary can be used to set multiple keys with a different expiration time:

local obj = resty_lock:new("reports_locks")
obj:lock("test", {exptime = 10})
obj:lock("test2", {exptime = 4})
obj:lock("test3", {exptime = 50})

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the resty_lock:new and obj:lock entry points, then trace how the dictionary-level exptime is applied to shared-memory dictionary entries. Done means the lock API accepts the per-key options shown and allows different expiration values for keys in one dictionary; verify the behavior with the relevant lock tests if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.