Skip to content

Commit aaca17c

Browse files
committed
added some description
1 parent 81f352f commit aaca17c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/service-library/src/servicelib/redis/_semaphore_lua.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
"""used to load a lua script from the package resources in memory
2+
3+
Example:
4+
>>> from servicelib.redis._semaphore_lua import ACQUIRE_SEMAPHORE_SCRIPT
5+
# This will register the script in redis and return a Script object
6+
# which can be used to execute the script. Even from multiple processes
7+
# the script will be loaded only once in redis as the redis server computes
8+
# the SHA1 of the script and uses it to identify it.
9+
>>> from aioredis import Redis
10+
>>> redis = Redis(...)
11+
>>> my_acquire_script = redis.register_script(
12+
ACQUIRE_SEMAPHORE_SCRIPT
13+
>>> my_acquire_script(keys=[...], args=[...])
14+
"""
15+
116
from importlib import resources
217
from typing import Final
318

419

520
def _load_script(script_name: str) -> str:
6-
with resources.path("servicelib", f"redis.lua.{script_name}ga") as script_file:
21+
with resources.path("servicelib.redis.lua", f"{script_name}.lua") as script_file:
722
return script_file.read_text(encoding="utf-8").strip()
823

924

0 commit comments

Comments
 (0)