using EonaCat.Cache.Sqlite;

namespace SqliteCacheTester
{
    public static class DnsCache
    {
        private static SqliteCache _cache;

        static DnsCache()
        {
            Init();
        }

        public static void Init()
        {
            _cache = new SqliteCache();
        }

        public static T? GetCacheAsync<T>(string cacheKey)
        {
            var cached = _cache.HasKey(cacheKey) ? _cache.Get<T>($"{cacheKey}") : default;
            return cached;
        }

        public static void SetCache<T>(string cacheKey,
            T cachedObject)
        {
            _cache.Set(cacheKey, cachedObject);
        }
    }
}
