FileCacheDriver constructor

FileCacheDriver({
  1. String cacheDir = 'storage/cache',
  2. int maxFileSize = 10 * 1024 * 1024,
  3. int compressionThreshold = 1024,
  4. bool enableCompression = true,
  5. int filePermissions = 0x644,
})

Creates a new FileCacheDriver instance.

cacheDir - The directory path where cache files will be stored. The directory will be created if it doesn't exist. (default: 'storage/cache') maxFileSize - Maximum size of individual cache files in bytes (default: 10MB) compressionThreshold - Size threshold for enabling compression (default: 1KB) enableCompression - Whether to enable gzip compression (default: true) filePermissions - File permissions for cache files (default: 0644)

Throws ArgumentError if cacheDir is empty or null. Throws FileSystemException if the cache directory cannot be created or is not writable.

Implementation

FileCacheDriver({
  String cacheDir = 'storage/cache',
  int maxFileSize = 10 * 1024 * 1024, // 10MB
  int compressionThreshold = 1024, // 1KB
  bool enableCompression = true,
  int filePermissions = 0x644, // rw-r--r--
})  : _cacheDir = cacheDir.trim(),
      _maxFileSize = maxFileSize,
      _compressionThreshold = compressionThreshold,
      _enableCompression = enableCompression,
      _filePermissions = filePermissions {
  if (_cacheDir.isEmpty) {
    throw ArgumentError('Cache directory path cannot be empty');
  }

  // Create cache directory if it doesn't exist
  _ensureCacheDirectory();

  // Load existing metadata if available
  _loadMetadata();
}