driver method

  1. @override
CacheDriver driver([
  1. String? name
])
override

Gets a specific cache driver instance.

If name is provided, returns the driver with that name. Otherwise, returns the default driver.

Throws CacheException if the requested driver is not registered.

Implementation

@override
CacheDriver driver([String? name]) {
  if (name != null) {
    _validator.validateDriverName(name);
    final driver = _driverRegistry.getDriver(name);
    if (driver == null) {
      throw CacheException('Cache driver "$name" not registered');
    }
    return driver;
  }
  return _driverRegistry.getDefaultDriver();
}