Created
February 26, 2018 03:04
-
-
Save barinek/62223089e9b5dbaa2c23c2dc104ee5b6 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
class InstanceDataGateway(val pool: JedisPool, val timeToLiveInMillis: Long) { | |
fun heartbeat(appId: String, url: String): InstanceRecord { | |
val resource = pool.resource | |
resource.psetex("$appId:$url", timeToLiveInMillis, url) | |
resource.close() | |
return InstanceRecord(appId, url) | |
} | |
fun findBy(appId: String): List<InstanceRecord> { | |
val list = mutableListOf<InstanceRecord>() | |
val resource = pool.resource | |
resource.keys("$appId:*") | |
.map { pool.resource.get(it) } | |
.mapTo(list) { InstanceRecord(appId, it) } | |
resource.close() | |
return list | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment