// Path: src/main/java/com/dukenlidb/nlidb/model/UserSession.java
// @Data
// @AllArgsConstructor
// public class UserSession {
// 
//     @JsonUnwrapped
//     private DBConnectionConfig dbConnectionConfig;
// 
//     public String serialize() throws JsonProcessingException {
//         return new ObjectMapper().writeValueAsString(this);
//     }
// 
//     public static UserSession deserialize(String str) throws IOException {
//         return new ObjectMapper().readValue(str, UserSession.class);
//     }
// 
// }


import com.fasterxml.jackson.core.JsonProcessingException;
import com.dukenlidb.nlidb.model.UserSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import java.io.IOException;
package com.dukenlidb.nlidb.service;



@Service
public class RedisService {

    private Jedis jedis;

    @Autowired
    public RedisService(
            @Value("${redis.host}") String host,
            @Value("${redis.port}") int port
    ) {
        jedis = new Jedis(host, port);
    }

    public boolean hasUser(String userId) {
        return jedis.exists(userId);
    }

    public void removeUser(String userId) {
        jedis.del(userId);
    }

    public void refreshUser(String userId) {
        jedis.expire(userId, 3600 * 24);
    }

// Path: src/main/java/com/dukenlidb/nlidb/model/UserSession.java
// @Data
// @AllArgsConstructor
// public class UserSession {
// 
//     @JsonUnwrapped
//     private DBConnectionConfig dbConnectionConfig;
// 
//     public String serialize() throws JsonProcessingException {
//         return new ObjectMapper().writeValueAsString(this);
//     }
// 
//     public static UserSession deserialize(String str) throws IOException {
//         return new ObjectMapper().readValue(str, UserSession.class);
//     }
// 
// }


// Path: src/main/java/com/dukenlidb/nlidb/service/RedisService.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.dukenlidb.nlidb.model.UserSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import java.io.IOException;

package com.dukenlidb.nlidb.service;



@Service
public class RedisService {

    private Jedis jedis;

    @Autowired
    public RedisService(
            @Value("${redis.host}") String host,
            @Value("${redis.port}") int port
    ) {
        jedis = new Jedis(host, port);
    }

    public boolean hasUser(String userId) {
        return jedis.exists(userId);
    }

    public void removeUser(String userId) {
        jedis.del(userId);
    }

    public void refreshUser(String userId) {
        jedis.expire(userId, 3600 * 24);
    }

    public UserSession getUserSession(String userId)