validateKey method

  1. @override
void validateKey(
  1. String key
)
override

Validates a cache key. Throws CacheException if the key is invalid.

Implementation

@override
void validateKey(String key) {
  if (key.isEmpty) {
    throw CacheException('Cache key cannot be empty');
  }

  // Check for potentially problematic characters
  if (key.contains('\x00')) {
    throw CacheException('Cache key cannot contain null characters');
  }

  // Check key length (reasonable limit to prevent issues)
  if (key.length > 250) {
    throw CacheException('Cache key is too long (maximum 250 characters)');
  }
}