Last active
September 9, 2015 20:41
-
-
Save bpoweski/e11ba6108021d436b5c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-field! [^Class klass instance ^String name] | |
(.get (doto (.getDeclaredField klass name) (.setAccessible true)) instance)) | |
(defn ^ScriptingCommands scripting-commands [conn] | |
(if (instance? JedisCluster conn) | |
(let [conn-handler (get-field! JedisCluster conn "connectionHandler") | |
max-redirections (get-field! JedisCluster conn "maxRedirections")] | |
(reify ScriptingCommands | |
(evalsha [this ^String sha1 ^java.util.List keys ^java.util.List args] | |
(.run (proxy [JedisClusterCommand] [conn-handler max-redirections] | |
(execute [connection] (.evalsha ^Jedis connection sha1 ^java.util.List (take 1 keys) args))) | |
(first keys))))) | |
conn)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment