Created
August 23, 2011 05:13
-
-
Save espeed/1164389 to your computer and use it in GitHub Desktop.
Talk to Redis while you walk Gremlin
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
// Talk to Redis while you walk Gremlin | |
// by James Thornton, http://jamesthornton.com | |
import redis.clients.jedis.*; | |
Jedis jedis = new Jedis("localhost"); | |
g = TinkerGraphFactory.createTinkerGraph(); | |
talk2redis = { | |
_().sideEffect{ jedis.incr(it.name); } | |
} | |
Gremlin.defineStep("talk", [Vertex,Pipe], talk2redis); | |
g.v(1).both.talk().loop(2){it.loops < 10} >> -1; | |
println "Marko: " + jedis.get("marko"); | |
println "Peter: " + jedis.get("peter"); | |
println "Josh: " + jedis.get("josh"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment