@sentio/runtime 3.1.0-rc.4 → 3.2.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -698,8 +698,52 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
698
698
  }
699
699
  declare function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType): void;
700
700
 
701
+ /**
702
+ * Configuration for the in-memory cache feature.
703
+ *
704
+ * The cache provides a key-value store that persists across handler invocations,
705
+ * allowing processors to store and retrieve computed values efficiently.
706
+ */
707
+ interface CacheConfig {
708
+ /**
709
+ * Whether the cache feature is enabled.
710
+ * When enabled, a MemoryCacheItem entity will be automatically added to the schema.
711
+ * @default true
712
+ */
713
+ enabled: boolean;
714
+ /**
715
+ * Maximum size of the cache in megabytes.
716
+ * Controls the memory limit for cached items.
717
+ * @default 100
718
+ */
719
+ size?: number;
720
+ }
721
+ /**
722
+ * Global configuration for the Sentio SDK runtime.
723
+ *
724
+ * This configuration controls execution behavior and optional features like caching.
725
+ * Settings here apply globally to all processors in the project.
726
+ */
701
727
  interface GlobalConfig {
728
+ /**
729
+ * Execution configuration controlling how handlers are processed.
730
+ * Includes settings for sequential vs parallel execution, block time handling, etc.
731
+ */
702
732
  execution: Partial<ExecutionConfig>;
733
+ /**
734
+ * Optional cache configuration for enabling in-memory key-value storage.
735
+ * When enabled, processors can use `ctx.cache` to store and retrieve values.
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * // In your processor handler:
740
+ * const cachedValue = await ctx.cache.get<number>('myKey')
741
+ * if (!cachedValue) {
742
+ * await ctx.cache.set('myKey', computedValue)
743
+ * }
744
+ * ```
745
+ */
746
+ cache?: CacheConfig;
703
747
  }
704
748
  declare const GLOBAL_CONFIG: GlobalConfig;
705
749
 
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  providerMetrics,
25
25
  recordRuntimeInfo,
26
26
  timeoutError
27
- } from "./chunk-TYDHN4Z6.js";
27
+ } from "./chunk-G6JGZJP4.js";
28
28
  import {
29
29
  Plugin,
30
30
  PluginManager
@@ -20,7 +20,7 @@ import {
20
20
  require_lib3,
21
21
  require_src,
22
22
  withAbort
23
- } from "./chunk-TYDHN4Z6.js";
23
+ } from "./chunk-G6JGZJP4.js";
24
24
  import {
25
25
  ExecutionConfig,
26
26
  HandlerType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "3.1.0-rc.4",
3
+ "version": "3.2.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,7 +1,54 @@
1
1
  import { ExecutionConfig } from './gen/processor/protos/processor.js'
2
2
 
3
+ /**
4
+ * Configuration for the in-memory cache feature.
5
+ *
6
+ * The cache provides a key-value store that persists across handler invocations,
7
+ * allowing processors to store and retrieve computed values efficiently.
8
+ */
9
+ export interface CacheConfig {
10
+ /**
11
+ * Whether the cache feature is enabled.
12
+ * When enabled, a MemoryCacheItem entity will be automatically added to the schema.
13
+ * @default true
14
+ */
15
+ enabled: boolean
16
+
17
+ /**
18
+ * Maximum size of the cache in megabytes.
19
+ * Controls the memory limit for cached items.
20
+ * @default 100
21
+ */
22
+ size?: number
23
+ }
24
+
25
+ /**
26
+ * Global configuration for the Sentio SDK runtime.
27
+ *
28
+ * This configuration controls execution behavior and optional features like caching.
29
+ * Settings here apply globally to all processors in the project.
30
+ */
3
31
  export interface GlobalConfig {
32
+ /**
33
+ * Execution configuration controlling how handlers are processed.
34
+ * Includes settings for sequential vs parallel execution, block time handling, etc.
35
+ */
4
36
  execution: Partial<ExecutionConfig>
37
+
38
+ /**
39
+ * Optional cache configuration for enabling in-memory key-value storage.
40
+ * When enabled, processors can use `ctx.cache` to store and retrieve values.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * // In your processor handler:
45
+ * const cachedValue = await ctx.cache.get<number>('myKey')
46
+ * if (!cachedValue) {
47
+ * await ctx.cache.set('myKey', computedValue)
48
+ * }
49
+ * ```
50
+ */
51
+ cache?: CacheConfig
5
52
  }
6
53
 
7
54
  // Experimental global config, only apply to eth for now
@@ -9,6 +56,9 @@ export const GLOBAL_CONFIG: GlobalConfig = {
9
56
  execution: {
10
57
  sequential: false,
11
58
  forceExactBlockTime: false
59
+ },
60
+ cache: {
61
+ enabled: true
12
62
  }
13
63
  }
14
64