entry: attrs.entrySet()) {
+ result.put(entry.getKey(), toObject(decoder, entry.getValue()));
+ }
+ return result;
+ }
+
+}
diff --git a/redisson-micronaut/src/main/java/org/redisson/micronaut/session/RedissonHttpSessionConfiguration.java b/redisson-micronaut/src/main/java/org/redisson/micronaut/session/RedissonHttpSessionConfiguration.java
new file mode 100644
index 000000000..62ad96546
--- /dev/null
+++ b/redisson-micronaut/src/main/java/org/redisson/micronaut/session/RedissonHttpSessionConfiguration.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright (c) 2013-2021 Nikita Koksharov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.redisson.micronaut.session;
+
+import io.micronaut.context.annotation.ConfigurationProperties;
+import io.micronaut.core.util.Toggleable;
+import io.micronaut.session.http.HttpSessionConfiguration;
+import org.redisson.client.codec.Codec;
+
+/**
+ * Micronaut Session settings.
+ *
+ * @author Nikita Koksharov
+ */
+@ConfigurationProperties("redisson")
+public class RedissonHttpSessionConfiguration extends HttpSessionConfiguration implements Toggleable {
+
+ public enum UpdateMode {WRITE_BEHIND, AFTER_REQUEST}
+
+ private String keyPrefix = "";
+ private Codec codec;
+ private UpdateMode updateMode = UpdateMode.AFTER_REQUEST;
+ private boolean broadcastSessionUpdates = false;
+
+ public boolean isBroadcastSessionUpdates() {
+ return broadcastSessionUpdates;
+ }
+
+ /**
+ * Defines broadcasting of session updates across all micronaut services.
+ *
+ * @param broadcastSessionUpdates - if true then session changes are broadcasted.
+ */
+ public void setBroadcastSessionUpdates(boolean broadcastSessionUpdates) {
+ this.broadcastSessionUpdates = broadcastSessionUpdates;
+ }
+
+ public UpdateMode getUpdateMode() {
+ return updateMode;
+ }
+
+ /**
+ * Defines session attributes update mode.
+ *
+ * WRITE_BEHIND - session changes stored asynchronously.
+ * AFTER_REQUEST - session changes stored only on io.micronaut.session.SessionStore#save(io.micronaut.session.Session) method invocation.
+ *
+ * Default is AFTER_REQUEST.
+ *
+ * @param updateMode - mode value
+ */
+ public void setUpdateMode(UpdateMode updateMode) {
+ this.updateMode = updateMode;
+ }
+
+ public Codec getCodec() {
+ return codec;
+ }
+
+ /**
+ * Redis data codec applied to session values.
+ * Default is MarshallingCodec codec
+ *
+ * @see org.redisson.client.codec.Codec
+ * @see org.redisson.codec.MarshallingCodec
+ *
+ * @param codec - data codec
+ * @return config
+ */
+ public void setCodec(Codec codec) {
+ this.codec = codec;
+ }
+
+ public String getKeyPrefix() {
+ return keyPrefix;
+ }
+
+ /**
+ * Defines string prefix applied to all objects stored in Redis.
+ *
+ * @param keyPrefix - key prefix value
+ */
+ public void setKeyPrefix(String keyPrefix) {
+ this.keyPrefix = keyPrefix;
+ }
+}
diff --git a/redisson-micronaut/src/main/java/org/redisson/micronaut/session/RedissonSession.java b/redisson-micronaut/src/main/java/org/redisson/micronaut/session/RedissonSession.java
new file mode 100644
index 000000000..d64ea38c2
--- /dev/null
+++ b/redisson-micronaut/src/main/java/org/redisson/micronaut/session/RedissonSession.java
@@ -0,0 +1,283 @@
+/**
+ * Copyright (c) 2013-2021 Nikita Koksharov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.redisson.micronaut.session;
+
+import edu.umd.cs.findbugs.annotations.NonNull;
+import io.micronaut.core.convert.value.MutableConvertibleValues;
+import io.micronaut.session.InMemorySession;
+import io.micronaut.session.Session;
+import org.redisson.api.*;
+import org.redisson.client.codec.IntegerCodec;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+
+/**
+ *
+ * @author Nikita Koksharov
+ *
+ */
+public class RedissonSession extends InMemorySession implements Session {
+
+ private static final String MAX_INACTIVE_INTERVAL_ATTR = "session:maxInactiveInterval";
+ private static final String LAST_ACCESSED_TIME_ATTR = "session:lastAccessedTime";
+ private static final String CREATION_TIME_ATTR = "session:creationTime";
+
+ private final RedissonSessionStore redissonManager;
+ private final RMap map;
+ private final RTopic topic;
+ private final RedissonHttpSessionConfiguration.UpdateMode updateMode;
+ private Instant creationTime;
+ private boolean broadcastSessionUpdates;
+
+ private Set removedAttributes = Collections.emptySet();
+ private Map updatedAttributes = Collections.emptyMap();
+
+ public RedissonSession(RedissonSessionStore redissonManager,
+ String id,
+ RedissonHttpSessionConfiguration.UpdateMode updateMode) {
+ this(redissonManager, id, updateMode, Duration.ZERO);
+ }
+
+ public RedissonSession(RedissonSessionStore redissonManager,
+ String id,
+ RedissonHttpSessionConfiguration.UpdateMode updateMode,
+ Duration maxInactiveInterval) {
+ super(id, maxInactiveInterval);
+ this.redissonManager = redissonManager;
+ this.updateMode = updateMode;
+ this.topic = redissonManager.getTopic();
+
+ if (updateMode == RedissonHttpSessionConfiguration.UpdateMode.AFTER_REQUEST) {
+ removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ updatedAttributes = new ConcurrentHashMap<>();
+ }
+
+ this.creationTime = super.getCreationTime();
+ super.setLastAccessedTime(creationTime);
+ map = redissonManager.getMap(getId());
+ }
+
+ @NonNull
+ @Override
+ public Instant getCreationTime() {
+ return creationTime;
+ }
+
+ @Override
+ public MutableConvertibleValues