Created
August 1, 2014 16:28
Why u no work
This file contains hidden or 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
@GrabResolver(name='clojars.org', root='http://clojars.org/repo') | |
@Grab('redis.embedded:embedded-redis:0.2') | |
@Grab('redis.clients:jedis:2.2.1') | |
@Grab('org.apache.ivy:ivy:2.3.0') | |
import redis.clients.jedis.Jedis | |
import redis.clients.jedis.JedisCommands | |
import redis.clients.jedis.JedisPool | |
import redis.clients.jedis.JedisPoolConfig | |
import redis.clients.jedis.Protocol | |
import redis.embedded.RedisServer | |
@RestController | |
class EmbeddedRedis { | |
Jedis jedis | |
@PostConstruct | |
void created(){ | |
int redisPort = 0 | |
ServerSocket serverSocket = new ServerSocket(0) | |
redisPort = serverSocket.localPort | |
serverSocket.close() | |
RedisServer redisServer = new RedisServer(redisPort) | |
redisServer.start() | |
jedis = new Jedis('127.0.0.1', redisPort) | |
jedis.set('monkey', 'hello monkey') | |
} | |
@RequestMapping('/') | |
String home() { | |
jedis.get('monkey') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment