summaryrefslogtreecommitdiff
path: root/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt
diff options
context:
space:
mode:
authormjkwiatkowski <mati.rewa@gmail.com>2026-06-15 23:48:44 +0200
committermjkwiatkowski <mati.rewa@gmail.com>2026-06-15 23:48:44 +0200
commit0731bd58889df127ef87aba2590d505d79e6646f (patch)
tree128aceeaf60ac5c098297f7cfda9fa47f974fc84 /opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt
parentf1ecbf0ce40d43685d8a6aeba0fe4cdebbd4536f (diff)
feat: migrated the past project to the sunfish repo
Diffstat (limited to 'opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt')
-rw-r--r--opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt43
1 files changed, 43 insertions, 0 deletions
diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt
new file mode 100644
index 00000000..b659d40a
--- /dev/null
+++ b/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt
@@ -0,0 +1,43 @@
+package org.opendc.common.utils
+
+import com.fasterxml.jackson.dataformat.toml.TomlMapper
+import redis.clients.jedis.RedisClient
+import redis.clients.jedis.StreamEntryID
+import redis.clients.jedis.params.XReadParams
+import java.util.Properties
+
+/**
+ * This class represents the Redis server instance.
+ * @author Mateusz Kwiatkowski
+ * @see <a href=https://redis.io/docs/latest/>https://redis.io/docs/latest/</a>
+ *
+ * @see <a href=https://redis.io/docs/latest/develop/data-types/streams/>https://redis.io/docs/latest/develop/data-types/streams/</a>
+ */
+
+@Suppress("DEPRECATION")
+public class Redis {
+ private var properties : Properties
+
+ init {
+ properties = TomlMapper().readerFor(Properties().javaClass)
+ .readValue(Kafka::class.java.getResource("/producer.toml"))
+ }
+
+ public fun run() {
+ val jedis : RedisClient = RedisClient.create("redis://localhost:6379")
+
+ val res5 = jedis.xread(
+ XReadParams.xReadParams().block(300).count(100),
+ object : HashMap<String?, StreamEntryID?>() {
+ init {
+ put("${properties.getProperty("table")}", StreamEntryID())
+ }
+ })
+
+ // in Redis you can subscribe to updates to a stream.
+ // you should base your application off this.
+ // you can listen for new items with XREAD
+ println(res5)
+ jedis.close()
+ }
+} \ No newline at end of file