@emailcheck/email-validator-js
Version:
Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.
46 lines (45 loc) • 1.54 kB
TypeScript
import type { CacheStore } from '../cache-interface';
/**
* Redis client interface to avoid direct dependency on redis package
*/
export interface RedisClient {
get(key: string): Promise<string | null>;
set(key: string, value: string, mode?: string, duration?: number): Promise<string | null>;
del(key: string): Promise<number>;
exists(key: string): Promise<number>;
flushdb(): Promise<string>;
}
/**
* Redis adapter for the cache interface
* Supports JSON serialization for complex objects
*/
export declare class RedisAdapter<T> implements CacheStore<T> {
private redis;
private keyPrefix;
private defaultTtlMs;
private jsonSerializer;
constructor(redis: RedisClient, options?: {
keyPrefix?: string;
defaultTtlMs?: number;
jsonSerializer?: {
stringify: (value: T) => string;
parse: (value: string) => T;
};
});
private getKey;
/**
* Recursively process an object to convert Date instances to a serializable format
*/
private processDatesForSerialization;
get(key: string): Promise<T | null>;
set(key: string, value: T, ttlMs?: number): Promise<void>;
delete(key: string): Promise<boolean>;
has(key: string): Promise<boolean>;
clear(): Promise<void>;
size(): number | undefined;
/**
* Helper method to delete only keys with the configured prefix
* Requires Redis SCAN command which might not be available in all Redis clients
*/
clearPrefixed(): Promise<void>;
}