You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-docs/influxdb3/core/v3/ref.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ tags:
118
118
InfluxDB 3 Core provides the InfluxDB 3 Processing engine, an embedded Python VM that can dynamically load and trigger Python plugins in response to events in your database.
119
119
Use Processing engine plugins and triggers to run code and perform tasks for different database events.
120
120
121
-
To get started with the Processing engine, see the [Processing engine and Python plugins](/influxdb3/core/processing-engine/) guide.
121
+
To get started with the Processing Engine, see the [Processing Engine and Python plugins](/influxdb3/core/processing-engine/) guide.
122
122
- name: Quick start
123
123
description: |
124
124
1. [Check the status](#section/Server-information) of the InfluxDB server.
Copy file name to clipboardExpand all lines: api-docs/influxdb3/enterprise/v3/ref.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ tags:
118
118
InfluxDB 3 Enterprise provides the InfluxDB 3 Processing engine, an embedded Python VM that can dynamically load and trigger Python plugins in response to events in your database.
119
119
Use Processing engine plugins and triggers to run code and perform tasks for different database events.
120
120
121
-
To get started with the Processing engine, see the [Processing engine and Python plugins](/influxdb3/enterprise/processing-engine/) guide.
121
+
To get started with the Processing Engine, see the [Processing Engine and Python plugins](/influxdb3/enterprise/processing-engine/) guide.
122
122
- name: Quick start
123
123
description: |
124
124
1. [Check the status](#section/Server-information) of the InfluxDB server.
The Processing engine logs all plugin errors to stdout and the `system.processing_engine_logs` system table.
237
+
The Processing Engine logs all plugin errors to stdout and the `system.processing_engine_logs` system table.
238
238
239
239
To configure additional error handling for a trigger, use the `--error-behavior` flag:
240
240
@@ -466,3 +466,153 @@ To run the plugin, you send an HTTP request to `<HOST>/api/v3/engine/my-plugin`.
466
466
Because all On Request plugins for a server share the same `<host>/api/v3/engine/` base URL,
467
467
the trigger-spec you define must be unique across all plugins configured for a server,
468
468
regardless of which database they are associated with.
469
+
470
+
471
+
## In-memory cache
472
+
473
+
The Processing Engine provides a powerful in-memory cache system that enables plugins to persist and retrieve data between executions. This cache system is essential for maintaining state, tracking metrics over time, and optimizing performance when working with external data sources.
474
+
475
+
### Key Benefits
476
+
477
+
-**State persistence**: Maintain counters, timestamps, and other state variables across plugin executions.
478
+
-**Performance and cost optimization**: Store frequently used data to avoid expensive recalculations. Minimize external API calls by caching responses and avoiding rate limits.
479
+
-**Data Enrichment**: Cache lookup tables, API responses, or reference data to enrich data efficiently.
480
+
481
+
### Cache API
482
+
483
+
The cache API is accessible via the `cache` property on the `influxdb3_local` object provided to all plugin types:
484
+
485
+
```python
486
+
# Basic usage pattern
487
+
influxdb3_local.cache.METHOD(PARAMETERS)
488
+
```
489
+
490
+
491
+
| Method | Parameters | Returns | Description |
492
+
|--------|------------|---------|-------------|
493
+
|`put`|`key` (str): The key to store the value under<br>`value` (Any): Any Python object to cache<br>`ttl` (Optional[float], default=None): Time in seconds before expiration<br>`use_global` (bool, default=False): If True, uses global namespace | None | Stores a value in the cache with an optional time-to-live |
494
+
|`get`|`key` (str): The key to retrieve<br>`default` (Any, default=None): Value to return if key not found<br>`use_global` (bool, default=False): If True, uses global namespace | Any | Retrieves a value from the cache or returns default if not found |
495
+
|`delete`|`key` (str): The key to delete<br>`use_global` (bool, default=False): If True, uses global namespace | bool | Deletes a value from the cache. Returns True if deleted, False if not found |
496
+
497
+
### Cache Namespaces
498
+
499
+
The cache system offers two distinct namespaces, providing flexibility for different use cases:
500
+
501
+
| Namespace | Scope | Best For |
502
+
| --- | --- | --- |
503
+
|**Trigger-specific** (default) | Isolated to a single trigger | Plugin state, counters, timestamps specific to one plugin |
504
+
|**Global**| Shared across all triggers | Configuration, lookup tables, service states that should be available to all plugins |
505
+
506
+
### Using the In-Memory Cache
507
+
508
+
The following examples show how to use the cache API in plugins:
influxdb3_local.info(f"This plugin has been executed {counter} times")
555
+
556
+
# Process writes normally...
557
+
```
558
+
559
+
#### Example: Sharing Configuration Across Triggers
560
+
561
+
One benefit of using a global namespace is being more responsive to changing conditions. This example demonstrates using the global namespace to share configuration, so a scheduled call can check thresholds placed by prior trigger calls, without making a query to the DB itself:
562
+
563
+
```python
564
+
defprocess_scheduled_call(influxdb3_local, time, args=None):
The cache is designed to support stateful operations while maintaining isolation between different triggers. Use the trigger-specific namespace for most operations and the global namespace only when data sharing across triggers is necessary.
587
+
588
+
### Best Practices
589
+
590
+
#### Use TTL Appropriately
591
+
Set realistic expiration times based on how frequently data changes.
-**Memory Usage**: Since cache contents are stored in memory, monitor your memory usage when caching large datasets.
617
+
-**Server Restarts**: The cache is cleared when the server restarts, so it's recommended you design your plugins to handle cache initialization (as noted above).
618
+
-**Concurrency**: Be cautious when multiple trigger instances might update the same cache key simultaneously to prevent inaccurate or out-of-date data access.
0 commit comments