package rd.service.cache;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import rd.data.db.table.*;

import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public class GlobalCache {
    public static final Cache<String, String> cookieCache = Caffeine.newBuilder()
            .expireAfterWrite(2, TimeUnit.HOURS)
            .initialCapacity(256)
            .maximumSize(2048)
            .build();

    public static final Cache<Long, Activity> activityCache = Caffeine.newBuilder()
            .expireAfterAccess(1, TimeUnit.DAYS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<String, Set<Activity>> termCache = Caffeine.newBuilder()
            .expireAfterAccess(1, TimeUnit.DAYS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<String, ActivityTarget> ActivityTargetCourseCache = Caffeine.newBuilder()
            .expireAfterAccess(1, TimeUnit.DAYS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<String, List<String>> userRoleCache = Caffeine.newBuilder()
            .expireAfterAccess(15, TimeUnit.DAYS)
            .initialCapacity(256)
            .maximumSize(2048)
            .build();

    public static final Cache<Long, Course> courseCache = Caffeine.newBuilder()
            .expireAfterAccess(1, TimeUnit.HOURS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<Long, Major> majorCache = Caffeine.newBuilder()
            .expireAfterAccess(30, TimeUnit.DAYS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<String, Major> majorNameCache = Caffeine.newBuilder()
            .expireAfterAccess(30, TimeUnit.DAYS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<Long, CourseSchedule> courseScheduleIdcache = Caffeine.newBuilder()
            .expireAfterAccess(1, TimeUnit.HOURS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<String, List<CourseSchedule>> courseScheduleCache = Caffeine.newBuilder()
            .expireAfterAccess(1, TimeUnit.HOURS)
            .initialCapacity(16)
            .maximumSize(64)
            .build();

    public static final Cache<String, UserBasic> usernameCache = Caffeine.newBuilder()
            .expireAfterWrite(2, TimeUnit.DAYS)
            .initialCapacity(256)
            .maximumSize(2048)
            .build();

    public static final Cache<Long, UserBasic> idCache = Caffeine.newBuilder()
            .expireAfterWrite(2, TimeUnit.DAYS)
            .initialCapacity(256)
            .maximumSize(2048)
            .build();

    public static final Cache<Long, Object> userInfoCache = Caffeine.newBuilder()
            .expireAfterWrite(2, TimeUnit.DAYS)
            .initialCapacity(256)
            .maximumSize(2048)
            .build();

    public static final Cache<Long, List<TeacherInfo>> courseAllTeacherCache = Caffeine.newBuilder()
            .expireAfterAccess(2, TimeUnit.DAYS)
            .initialCapacity(256)
            .maximumSize(2048)
            .build();
}
