CacheKey class

CacheKey

Annotation for Cached package.

Annotation that must be above a field in a method and must contain constant function that will return cache key for provided field value

Example

Use @CacheKey annotation

@cached
Future<int> getInt(
  @CacheKey(cacheKeyGenerator: exampleCacheFunction) int test) async {
  await Future.delayed(Duration(milliseconds: 20));
  return test;
}

String exampleCacheFunction(dynamic value) {
  return value.toString();
}
Annotations
  • @Target({TargetKind.parameter})

Constructors

CacheKey.new(CacheKeyGeneratorFunc cacheKeyGenerator)
const

Properties

cacheKeyGenerator CacheKeyGeneratorFunc
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited