Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
92edfb12
Commit
92edfb12
authored
Jun 07, 2021
by
Wout De Nolf
Browse files
Utility methods for server-side Redis scripts
parent
7ed2d43b
Changes
1
Hide whitespace changes
Inline
Side-by-side
bliss/config/conductor/redis_scripts.py
0 → 100644
View file @
92edfb12
"""Utilities for Redis server-side scripts
"""
_SCRIPTS
=
dict
()
def
register_script
(
redisproxy
,
script_name
:
str
,
script
:
str
)
->
None
:
"""Local registration. The registration with the Redis server is
done on first usage.
"""
if
script_name
in
_SCRIPTS
:
return
scriptobj
=
redisproxy
.
register_script
(
script
)
scriptobj
.
registered_client
=
None
# scriptobj only contains the script hash and code
_SCRIPTS
[
script_name
]
=
scriptobj
def
evaluate_script
(
redisproxy
,
script_name
:
str
,
keys
=
tuple
(),
args
=
tuple
()):
"""Evaluate a server-side Redis script
"""
if
script_name
not
in
_SCRIPTS
:
raise
RuntimeError
(
f
"Redis script
{
repr
(
script_name
)
}
is not registered"
)
scriptobj
=
_SCRIPTS
[
script_name
]
return
scriptobj
(
keys
=
keys
,
args
=
args
,
client
=
redisproxy
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment