package com.seer.teach.openapi.cache;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * User SSE 缓存 Service 层，使用 String 类型 SN 作为用户标识。
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class OpenApiSseLifeCycleCacheService {

    public static final String AI_CORRECT_REDIS_KEY_PREFIX = "OpenApiSseCorrectLifeCycle:";

    private final OpenApiSseLifeCycleCache openApiSseLifeCycleCache;

    public Integer getSession(String prefix, String sn) {
        return openApiSseLifeCycleCache.get(prefix, sn);
    }

    public void saveSession(String prefix, String sn, Integer sessionId) {
        openApiSseLifeCycleCache.put(prefix, sn, sessionId);
    }

    public void removeSession(String prefix, String sn) {
        openApiSseLifeCycleCache.invalidate(prefix, sn);
    }

}
