def _script_load(script):
script = script.encode('<STR_LIT:utf-8>') if isinstance(script, six.text_type) else script<EOL>sha = [None, sha1(script).hexdigest()]<EOL>def call(conn, keys=[], args=[], force_eval=False):<EOL><INDENT>keys = tuple(keys)<EOL>args = tuple(args)<EOL>if not force_eval:<EOL><INDENT>if not sha[<NUM_LIT:0>]:<EOL><INDENT>try:<EOL><INDENT>return conn.execute_command(<EOL>'<STR_LIT>', script, len(keys), *(keys + args))<EOL><DEDENT>finally:<EOL><INDENT>del sha[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>try:<EOL><INDENT>return conn.execute_command(<EOL>"<STR_LIT>", sha[<NUM_LIT:0>], len(keys), *(keys+args))<EOL><DEDENT>except redis.exceptions.ResponseError as msg:<EOL><INDENT>if not any(msg.args[<NUM_LIT:0>].startswith(nsm) for nsm in NO_SCRIPT_MESSAGES):<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>return conn.execute_command(<EOL>"<STR_LIT>", script, len(keys), *(keys+args))<EOL><DEDENT>return call<EOL>
Borrowed/modified from my book, Redis in Action:
https://github.com/josiahcarlson/redis-in-action/blob/master/python/ch11_listing_source.py

Used for Lua scripting support when writing against Redis 2.6+ to allow
for multiple unique columns per model.