Skip to content

Instantly share code, notes, and snippets.

@bpoweski
Last active September 9, 2015 20:41
Show Gist options
  • Save bpoweski/e11ba6108021d436b5c9 to your computer and use it in GitHub Desktop.
Save bpoweski/e11ba6108021d436b5c9 to your computer and use it in GitHub Desktop.
(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