Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2013-2024 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.core.annotation.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