There's a very easy way to do this with Groovy Grapes and the spymemcached client (and the Groovy Console as a "UI"). Just @Grab the spymemcached JAR, connect a client, and off you go:
The script is as simple as this:
@Grab('net.spy:spymemcached:2.10.5')
import net.spy.memcached.MemcachedClient
def memcachedClient = new MemcachedClient( new InetSocketAddress('127.0.0.1', 11211 ) );
memcachedClient.set('myKey',3600, "Hello world!")
memcachedClient.set('intKey',3600, 45)
println "myKey = ${memcachedClient.get('myKey')}"
println "intKey = ${memcachedClient.get('intKey')}"
It's pretty easy to change this to a command-line interface (CLI) to take parameters for keys, expiration times, etc. Note I'm using the synchronous gets/sets but this is just for testing.
Anyway this came about while writing my Memcached Input/Output step plugins for PDI, keep your eye on the Marketplace, I hope to have them released this week. Cheers!
No comments:
Post a Comment