File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/service-library/src/servicelib/redis Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 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+
116from importlib import resources
217from typing import Final
318
419
520def _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
You can’t perform that action at this time.
0 commit comments