@nasriya/cachify
Version:
A lightweight, extensible in-memory caching library for storing anything, with built-in TTL and customizable cache types.
54 lines (53 loc) • 2.82 kB
TypeScript
import type { BackupParameters, PersistanceStorageServices, RestoreParameters, StorageServices } from "../../core/persistence/docs";
import PersistenceManager from "../../core/persistence/persistence.manager";
import CachifyClient from "../../client";
declare class ExtPersistenceManager {
#private;
constructor(persistence: PersistenceManager, client: CachifyClient);
/**
* Initiates a backup process for the specified cache flavor and storage service.
*
* This function dispatches the backup operation to the appropriate cache manager
* based on the provided cache flavor. The `kvs` flavor targets the key-value cache,
* while the `files` flavor targets the file cache.
*
* @template F - The cache flavor type, indicating the cache source.
* @template S - The type of storage service to back up to.
* @param {S} to - The target storage service for the backup.
* @param {...BackupParameters<S>} args - Additional parameters for the backup operation.
* @returns {Promise<void>} Resolves when the backup operation completes.
* @throws {Error} If the specified cache flavor is unsupported.
*/
backup<S extends StorageServices>(to: S, ...args: BackupParameters<S>): Promise<void>;
/**
* Initiates a restore process from the specified storage service for all cache flavors.
*
* This function dispatches the restore operation to the appropriate cache manager
* based on the provided cache flavor. The `kvs` flavor targets the key-value cache,
* while the `files` flavor targets the file cache.
*
* @template S - The type of storage service to restore from.
* @param {S} service - The target storage service for the restore.
* @param {...RestoreParameters<S>} args - Additional parameters for the restore operation.
* @returns {Promise<void>} Resolves when the restore operation completes.
* @throws {Error} If the specified cache flavor is unsupported.
*/
restore<S extends StorageServices>(service: S, ...args: RestoreParameters<S>): Promise<void>;
/**
* Schedules a persistence operation for the specified cache flavor and storage service.
*
* This function is a no-op until the persistence manager is fully implemented.
*
*/
schedule(): void;
/**
* Registers a persistence service with the external persistence manager.
*
* @template S - The type of storage service.
* @param {S} service - The type of storage service to be added.
* @param {PersistanceStorageServices[S]['configs']} configs - The configuration settings for the service.
* @since v1.0.0
*/
use<S extends StorageServices>(service: S, configs: PersistanceStorageServices[S]['configs']): void;
}
export default ExtPersistenceManager;