package com.lingniu.ingest.session;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.time.Duration;
import java.util.Locale;

@ConfigurationProperties(prefix = "lingniu.ingest.session")
public class SessionProperties {

    private String store = "redis";

    private Duration ttl = Duration.ofMinutes(30);

    public String getStore() {
        return store;
    }

    public void setStore(String store) {
        String value = store == null || store.isBlank() ? "redis" : store.trim().toLowerCase(Locale.ROOT);
        if (!"redis".equals(value)) {
            throw new IllegalStateException("session.store supports only redis; configured value: " + store);
        }
        this.store = value;
    }

    public Duration getTtl() {
        return ttl;
    }

    public void setTtl(Duration ttl) {
        this.ttl = ttl;
    }

}
