Cache Set¶
Class: CacheSetBlockV1
Source: inference.core.workflows.core_steps.cache.cache_set.v1.CacheSetBlockV1
Store a value in an in-memory cache by key, using the image's video identifier as a namespace to enable data sharing between workflow steps, caching intermediate results, and avoiding redundant computations within the same workflow execution context.
How This Block Works¶
This block stores values in an in-memory cache that can be later retrieved using the Cache Get block. The block:
- Receives image, cache key, and value to store:
- Takes an input image to determine the cache namespace
- Receives a cache key (string) identifying the cache entry
- Receives a value (any data type) to store in the cache
- Determines cache namespace:
- Extracts video identifier from the image's video metadata
- Uses the video identifier as the cache namespace (isolates cache entries per video/stream)
- Falls back to "default" namespace if no video identifier is present
- Stores value in cache:
- Accesses the in-memory cache dictionary for the determined namespace
- Stores the value using the specified key in the cache
- Overwrites any existing value with the same key (cache keys are unique within a namespace)
- Returns stored value:
- Outputs the stored value as a pass-through (same value that was stored)
- The output can be used by subsequent workflow steps
The cache is namespaced by video identifier, meaning different videos or streams have separate cache storage. This allows workflows processing multiple videos to maintain separate caches for each video. The cache is stored in memory and is cleared when the workflow execution completes or when the block is destroyed. Cache Set must be used in conjunction with Cache Get - values are stored with Cache Set and retrieved with Cache Get using the same key and namespace (determined by the same video identifier).
Common Use Cases¶
- Shared State Between Steps: Store intermediate results in one workflow step for retrieval in another step (e.g., store detection results for later analysis, cache classification predictions for filtering, save metadata for subsequent blocks), enabling state sharing workflows
- Avoid Redundant Computations: Cache expensive computation results for reuse across multiple workflow steps (e.g., cache model predictions, store processed images, save transformation results), enabling computation caching workflows
- Video Frame Context: Maintain context across video frames by storing frame-specific data (e.g., cache previous frame detections, store frame sequence metadata, save tracking state), enabling frame context workflows
- Conditional Workflow Logic: Store decision results or flags that control workflow execution in subsequent steps (e.g., cache filtering decisions, store validation results, save workflow state), enabling conditional execution workflows
- Data Aggregation: Accumulate data across workflow steps by storing values in cache (e.g., store detection counts, cache statistics, save result collections), enabling data aggregation workflows
- Temporary Storage: Use cache as temporary storage for values that need to be accessed by multiple workflow steps without passing through the workflow graph (e.g., store cross-step data, maintain temporary state, share non-linear workflow data), enabling temporary storage workflows
Connecting to Other Blocks¶
This block stores values in cache and passes through the stored value:
- Before Cache Get block to store values that will be retrieved later (e.g., store detections for retrieval, cache predictions for later use, save metadata for access), enabling cache storage workflows
- After model or processing blocks to cache their outputs for later use (e.g., cache model predictions, store processed results, save computation outputs), enabling result caching workflows
- In workflow branches to store shared values accessible from parallel or conditional execution paths (e.g., store shared state, cache common results, save branch data), enabling branch coordination workflows
- Before blocks that need cached data to store values that will be used by subsequent blocks (e.g., store inputs for later processing, cache data for filtering, save values for analysis), enabling cached data workflows
- In conditional logic workflows to store flags or decisions for later use (e.g., store validation results, cache decision flags, save conditional state), enabling conditional logic workflows
- With video processing workflows to maintain frame-specific or video-specific cache namespaces (e.g., store frame context, cache video-specific data, save stream-specific values), enabling video context workflows
Requirements¶
This block requires an input image (used to determine the cache namespace via video identifier), a cache key (string) to identify the cache entry, and a value (any data type) to store. The block only works in LOCAL execution mode - it will raise a NotImplementedError if used in other execution modes. Values stored in the cache can be retrieved later using the Cache Get block with the same key and namespace (same video identifier). The cache is stored in memory and is automatically cleared when the workflow execution completes. The cache is namespaced by video identifier, so different videos have separate cache storage. If a key already exists in the cache, storing a new value with the same key will overwrite the previous value. The stored value can be any data type (strings, numbers, lists, detections, images, etc.).
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/cache_set@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | โ |
key |
str |
Cache key (string) identifying the cache entry where the value will be stored. The key must be used with the same value when retrieving the value with the Cache Get block. Keys are case-sensitive and must be exact matches. If a key already exists in the cache, storing a new value will overwrite the previous value. Use descriptive keys to identify different cached values (e.g., 'detections', 'classification_result', 'frame_metadata').. | โ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Runtime compatibility¶
-
hardโ executionremote - Cache blocks only support LOCAL workflow step execution; remote step execution raises NotImplementedError.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Cache Set in version v1.
- inputs:
Crop Visualization,Image Slicer,ByteTrack Tracker,Google Gemini,SAM 3 Interactive,Time in Zone,Velocity,Image Slicer,Template Matching,Pixel Color Count,Multi-Label Classification Model,SIFT Comparison,Mask Area Measurement,Morphological Transformation,Background Subtraction,BoT-SORT Tracker,Ellipse Visualization,MoonshotAI Kimi,Multi-Label Classification Model,SAM 3,Grid Visualization,PLC ModbusTCP,Semantic Segmentation Model,Google Gemma,Byte Tracker,Overlap Filter,OpenAI,Multi-Label Classification Model,Path Deviation,Depth Estimation,Image Preprocessing,OPC UA Writer Sink,Detections Stabilizer,QR Code Detection,Stitch Images,Google Vision OCR,OpenAI,QR Code Generator,Florence-2 Model,Polygon Zone Visualization,Detection Offset,Cache Set,Contrast Equalization,VLM As Classifier,Clip Comparison,Pixelate Visualization,SORT Tracker,Qwen 3.6 API,Dot Visualization,Stability AI Outpainting,Byte Tracker,Keypoint Visualization,Anthropic Claude,PP-OCR,Anthropic Claude,Image Stack,Roboflow Visual Search Classifier,PTZ Tracking (ONVIF),Semantic Segmentation Model,Image Threshold,First Non Empty Or Default,JSON Parser,S3 Sink,MQTT Writer,Qwen-VL,CLIP Embedding Model,Stitch OCR Detections,Detections Consensus,SIFT,Nearest Neighbor Detection Match,Stitch OCR Detections,Auto Rotate on Edges,Time in Zone,VLM As Classifier,Instance Segmentation Model,Dimension Collapse,Trace Visualization,Seg Preview,EasyOCR,Camera Focus,Google Gemma API,PLC EthernetIP,Property Definition,OC-SORT Tracker,MoonshotAI Kimi,Distance Measurement,Data Aggregator,Blur Visualization,Path Deviation,Image Convert Grayscale,Microsoft SQL Server Sink,Barcode Detection,Moondream2,Clip Comparison,Dynamic Zone,Reference Path Visualization,Email Notification,Roboflow Visual Search,Environment Secrets Store,Rate Limiter,Keypoint Detection Model,Contrast Enhancement,GLM-OCR,Byte Tracker,Camera Focus,Heatmap Visualization,Roboflow Vision Events,OpenAI-Compatible LLM,Qwen2.5-VL,Label Visualization,Buffer,Single-Label Classification Model,Keypoint Detection Model,Detections Merge,Line Counter,Detections Filter,Anthropic Claude,Detection Event Log,Roboflow Dataset Upload,Instance Segmentation Model,Classification Label Visualization,Mask Edge Snap,Dynamic Crop,Per-Class Confidence Filter,Detections Transformation,Absolute Static Crop,Detections Classes Replacement,Overlap Analysis,Current Time,Expression,Cache Get,Roboflow Custom Metadata,Line Counter Visualization,OpenAI,Bounding Box Visualization,Morphological Transformation,Segment Anything 2 Model,Perception Encoder Embedding Model,Object Detection Model,Cosmos 3,Motion Detection,Cosine Similarity,Webhook Sink,VLM As Detector,Size Measurement,Bounding Rectangle,Single-Label Classification Model,SAM 3,Roboflow Dataset Upload,OpenAI,SAM2 Video Tracker,Qwen3.5,Camera Calibration,Qwen3-VL,SAM3 Video Tracker,Detections List Roll-Up,PLC Writer,CSV Formatter,Detections Stitch,Track Class Lock,Triangle Visualization,Stability AI Image Generation,Icon Visualization,Relative Static Crop,VLM As Detector,OCR Model,SAM 3,GeoTag Detection,Qwen 3.5 API,Halo Visualization,OpenRouter,Frame Delay,Local File Sink,Text Display,Roboflow Asset Library Attributes,LMM,Image Blur,Gaze Detection,Inner Workflow,Color Visualization,Corner Visualization,Continue If,Instance Segmentation Model,Google Gemini,Slack Notification,Event Writer,Identify Outliers,Google Gemini,Twilio SMS Notification,Single-Label Classification Model,Perspective Correction,Object Detection Model,Instance Segmentation Model,Twilio SMS/MMS Notification,Polygon Visualization,Model Monitoring Inference Aggregator,Stability AI Inpainting,Florence-2 Model,Qwen3.5-VL,Dominant Color,Delta Filter,Mask Visualization,Polygon Visualization,SIFT Comparison,Switch Case,Halo Visualization,SmolVLM2,Llama 3.2 Vision,Detections Combine,CogVLM,Circle Visualization,Image Contours,Line Counter,Llama 3.2 Vision,YOLO-World Model,Time in Zone,Background Color Visualization,Keypoint Detection Model,PLC Reader,Model Comparison Visualization,LMM For Classification,Object Detection Model,Email Notification,Identify Changes - outputs:
Crop Visualization,Image Slicer,Detection Event Log,Roboflow Dataset Upload,Instance Segmentation Model,ByteTrack Tracker,Google Gemini,Classification Label Visualization,Mask Edge Snap,Dynamic Crop,SAM 3 Interactive,Detections Transformation,Time in Zone,Per-Class Confidence Filter,Velocity,Image Slicer,Absolute Static Crop,Detections Classes Replacement,Overlap Analysis,Template Matching,Cache Get,Expression,Pixel Color Count,Current Time,Roboflow Custom Metadata,Multi-Label Classification Model,SIFT Comparison,Mask Area Measurement,Morphological Transformation,Background Subtraction,BoT-SORT Tracker,Line Counter Visualization,OpenAI,Ellipse Visualization,Multi-Label Classification Model,MoonshotAI Kimi,SAM 3,Grid Visualization,PLC ModbusTCP,Segment Anything 2 Model,Semantic Segmentation Model,Bounding Box Visualization,Morphological Transformation,Google Gemma,Perception Encoder Embedding Model,Object Detection Model,Byte Tracker,Cosmos 3,Motion Detection,Overlap Filter,OpenAI,Multi-Label Classification Model,Cosine Similarity,Webhook Sink,VLM As Detector,Path Deviation,Size Measurement,Depth Estimation,Image Preprocessing,OPC UA Writer Sink,Detections Stabilizer,Bounding Rectangle,Single-Label Classification Model,SAM 3,Line Counter,QR Code Detection,Stitch Images,Roboflow Dataset Upload,OpenAI,SAM2 Video Tracker,Qwen3.5,Camera Calibration,Google Vision OCR,OpenAI,QR Code Generator,Florence-2 Model,Qwen3-VL,Polygon Zone Visualization,Detection Offset,Cache Set,Contrast Equalization,SAM3 Video Tracker,VLM As Classifier,Detections List Roll-Up,Clip Comparison,Pixelate Visualization,SORT Tracker,Qwen 3.6 API,PLC Writer,CSV Formatter,Detections Stitch,Track Class Lock,Triangle Visualization,Stability AI Image Generation,Icon Visualization,Dot Visualization,Stability AI Outpainting,Keypoint Visualization,Byte Tracker,Anthropic Claude,Relative Static Crop,PP-OCR,Anthropic Claude,Image Stack,Roboflow Visual Search Classifier,VLM As Detector,OCR Model,SAM 3,GeoTag Detection,PTZ Tracking (ONVIF),Qwen 3.5 API,Halo Visualization,OpenRouter,Frame Delay,Semantic Segmentation Model,Local File Sink,Text Display,Roboflow Asset Library Attributes,LMM,Image Threshold,Gaze Detection,Color Visualization,Image Blur,Inner Workflow,Corner Visualization,JSON Parser,First Non Empty Or Default,S3 Sink,MQTT Writer,Continue If,Qwen-VL,Instance Segmentation Model,CLIP Embedding Model,Google Gemini,Stitch OCR Detections,Slack Notification,Event Writer,Detections Consensus,Identify Outliers,SIFT,Nearest Neighbor Detection Match,VLM As Classifier,Google Gemini,Time in Zone,Stitch OCR Detections,Auto Rotate on Edges,Instance Segmentation Model,Dimension Collapse,Twilio SMS Notification,Trace Visualization,Single-Label Classification Model,Perspective Correction,Seg Preview,EasyOCR,Camera Focus,Google Gemma API,PLC EthernetIP,Property Definition,Object Detection Model,Instance Segmentation Model,OC-SORT Tracker,MoonshotAI Kimi,Distance Measurement,Data Aggregator,Twilio SMS/MMS Notification,Blur Visualization,Path Deviation,LMM For Classification,Polygon Visualization,Model Monitoring Inference Aggregator,Stability AI Inpainting,Image Convert Grayscale,Microsoft SQL Server Sink,Florence-2 Model,Qwen3.5-VL,Barcode Detection,Moondream2,Dominant Color,Clip Comparison,Delta Filter,Dynamic Zone,Mask Visualization,Reference Path Visualization,Email Notification,Polygon Visualization,Roboflow Visual Search,SIFT Comparison,Switch Case,Halo Visualization,SmolVLM2,Rate Limiter,Keypoint Detection Model,Contrast Enhancement,Llama 3.2 Vision,Detections Combine,GLM-OCR,CogVLM,Byte Tracker,Circle Visualization,Image Contours,Camera Focus,Heatmap Visualization,Roboflow Vision Events,Line Counter,Llama 3.2 Vision,YOLO-World Model,OpenAI-Compatible LLM,Qwen2.5-VL,Label Visualization,Time in Zone,Background Color Visualization,Keypoint Detection Model,PLC Reader,Buffer,Single-Label Classification Model,Model Comparison Visualization,Keypoint Detection Model,Detections Merge,Detections Filter,Object Detection Model,Email Notification,Anthropic Claude,Identify Changes
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Cache Set in version v1 has.
Bindings
-
input
image(image): Input image used to determine the cache namespace. The block extracts the video identifier from the image's video metadata and uses it as the cache namespace. If no video identifier is present, the block uses 'default' as the namespace. The namespace isolates cache entries so different videos or streams have separate cache storage. Use the same image (with the same video identifier) for both Cache Set and Cache Get blocks to access the same cache namespace..key(string): Cache key (string) identifying the cache entry where the value will be stored. The key must be used with the same value when retrieving the value with the Cache Get block. Keys are case-sensitive and must be exact matches. If a key already exists in the cache, storing a new value will overwrite the previous value. Use descriptive keys to identify different cached values (e.g., 'detections', 'classification_result', 'frame_metadata')..value(Union[list_of_values,*]): Value to store in the cache. Can be any data type including strings, numbers, lists, detections, images, classifications, or any other workflow data type. The value is stored in memory and can be retrieved later using the Cache Get block with the same key and namespace. The value is also passed through as the block's output, allowing it to be used by subsequent workflow steps..
-
output
output(*): Equivalent of any element.
Example JSON definition of step Cache Set in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/cache_set@v1",
"image": "$inputs.image",
"key": "my_cache_key",
"value": "any_value"
}