import { setupCache } from './api';

export const CacheFetchUrl = setupCache('fetch-url', 60 * 10);
export const CacheCmsContent = setupCache('cms-content', 60 * 5);
export const CacheCouchDbConnect = setupCache('couchdb-auth', 60 * 60 * 6, 'couchdb-auth-session');

export const CacheShopeeSellerProductTime = setupCache('shopee-seller-time-update', 60 * 10);
export const CacheShopeeSellerProductList = setupCache('shopee-seller-product-list', 60 * 5);
export const CacheShopeeSellerProductId = setupCache('shopee-seller-product-id', 60 * 2);

export const CacheShopeeAtrribute = setupCache('shopee-attribute', 60 * 5);
export const CacheShopeeProduct = setupCache('shopee-product-get', 60 * 10);
export const CacheShopeeStock = setupCache('shopee-product-stock', 60 * 60);

export const CacheShopeeShop = setupCache('shopee-shop-get', 60 * 60);
export const CacheShopeeShopSearch = setupCache('shopee-shop-search', 60 * 60 * 5);
export const CacheShopeeProductSearch = setupCache('shopee-product-search', 60 * 60 * 5);
export const CacheShopeeReview = setupCache('shopee-review', 60 * 60);
export const CacheShopeeAny = setupCache('shopee-any', 60);
export const CacheShopeeSellerConfig = setupCache('shopee-seller-config', 60 * 10);

export const CacheTiktokProductId = setupCache('tiktok-product-id', 60 * 10);
export const CacheTiktokProductSearch = setupCache('tiktok-product-search', 60 * 10);
export const CacheTiktokImageShopee = setupCache('tiktok-image-to-shopee', 60 * 60 * 24);

export const CacheOrderPdfBuffer = setupCache('order-pdf-buffer', 60 * 60);

export const cacheDestroyAll = () => {
  return Promise.allSettled([
    CacheFetchUrl.destroy(),
    CacheCmsContent.destroy(),
    CacheCouchDbConnect.destroy(),
    CacheShopeeSellerProductTime.destroy(),
    CacheShopeeSellerProductList.destroy(),
    CacheShopeeSellerProductId.destroy(),
    CacheShopeeAtrribute.destroy(),
    CacheShopeeProduct.destroy(),
    CacheShopeeStock.destroy(),
    CacheShopeeShop.destroy(),
    CacheShopeeShopSearch.destroy(),
    CacheShopeeProductSearch.destroy(),
    CacheShopeeReview.destroy(),
    CacheShopeeAny.destroy(),
    CacheShopeeSellerConfig.destroy(),
    CacheTiktokProductId.destroy(),
    CacheTiktokProductSearch.destroy(),
    CacheTiktokImageShopee.destroy(),
    CacheOrderPdfBuffer.destroy(),
  ]);
};
