beforeInvocation<T> method

  1. @override
FutureOr<void> beforeInvocation<T>(
  1. MethodInvocation<T> invocation
)

Executed immediately before the target method invocation.

May perform any synchronous or asynchronous operation.

Parameters

  • invocation: The current MethodInvocation representing the call context.

Returns

A FutureOr<void> indicating completion of pre-invocation tasks.

Implementation

@override
FutureOr<void> beforeInvocation<T>(MethodInvocation<T> invocation) async {
  // Pre-eviction: CacheEvict with beforeInvocation = true
  final cacheEvict = invocation.getMethod().getDirectAnnotation<CacheEvict>();

  if (cacheEvict != null && cacheEvict.beforeInvocation) {
    final operation = CacheEvictOperation(cacheEvict);
    final context = _getOrCreate().withInvocation(invocation);
    await operation.execute(context);
  }
}