Type Alias CacheSettingsBase<TType>

CacheSettingsBase: {
    defaultJitter?: number | null;
    defaultTtl?: ITimeSpan | null;
    eventBus?: EventBusInput;
    executionContext?: IExecutionContext;
    lockFactory?: LockFactoryInput;
    namespace?: INamespace;
    schema?: StandardSchemaV1<TType>;
    shouldValidateOutput?: boolean;
    waitUntil?: WaitUntil;
}

Base configuration shared by all Cache variants. Provides optional schema validation for all cached values.

IMPORT_PATH: "@daiso-tech/core/cache"

Type Parameters

  • TType = unknown

Type declaration

  • OptionaldefaultJitter?: number | null

    You can pass jitter value to ensure the backoff will not execute at the same time. If you pas null you can disable the jitrter.

    0.2
    
  • OptionaldefaultTtl?: ITimeSpan | null

    You can decide the default ttl value. If null is passed then no ttl will be used by default.

    null
    
  • OptionaleventBus?: EventBusInput

    You can provide an IEventBus or an IEventBusAdapter instance to handle the component's events. If you provide an adapter, it will be automatically wrapped in an EventBus instance.

    import { NoOpEventBusAdapter } from "@daiso-tech/core/event-bus/no-op-event-bus-adapter";

    new NoOpEventBusAdapter()
  • OptionalexecutionContext?: IExecutionContext

    You can pass IExecutionContext that will be used by context-aware adapters.

    import { ExecutionContext } from "@daiso-tech/core/execution-context"
    import { NoOpExecutionContextAdapter } from "@daiso-tech/core/execution-context/no-op-execution-context-adapter"

    new ExecutionContext(new NoOpExecutionContextAdapter())
  • OptionallockFactory?: LockFactoryInput

    You can provide an ILockFactoryBase, an ILockAdapter or an IDatabaseLockAdapter instance to handle locking when GetOrAddSettings.enableLocking is set to true during a getOrAdd call. If you provide an adapter, it will be automatically wrapped in an LockFactory instance.

    import { NoOpLockAdapter } from "@daiso-tech/core/lock/no-op-lock-adapter";

    new NoOpLockAdapter()
  • Optionalnamespace?: INamespace
    import { NoOpNamespace } from "@daiso-tech/core/namespace";

    new NoOpNamespace()
  • Optionalschema?: StandardSchemaV1<TType>

    You can provide any standard schema compliant object to validate all input and output data to ensure runtime type safety.

  • OptionalshouldValidateOutput?: boolean

    You can enable validating cache values when retrieving them.

    true
    
  • OptionalwaitUntil?: WaitUntil

    You can pass the waitUntil function to handle background promises. This is required when working with environments like Cloudflare Workers or Vercel Functions to ensure tasks complete after the response is sent.

    import { defaultWaitUntil } from "@daiso-tech/core/utilities"