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:
Camera Focus,Current Time,Camera Focus,Image Preprocessing,Background Subtraction,Multi-Label Classification Model,Color Visualization,Mask Visualization,Segment Anything 2 Model,Seg Preview,Multi-Label Classification Model,JSON Parser,Cache Set,Google Vision OCR,SIFT Comparison,Single-Label Classification Model,Google Gemini,Instance Segmentation Model,Llama 3.2 Vision,Contrast Enhancement,Keypoint Detection Model,Keypoint Visualization,First Non Empty Or Default,Camera Calibration,VLM As Detector,Twilio SMS Notification,Expression,LMM For Classification,Barcode Detection,Perspective Correction,Cache Get,Detection Offset,CLIP Embedding Model,OpenAI-Compatible LLM,Clip Comparison,Qwen-VL,Model Comparison Visualization,PLC EthernetIP,Dot Visualization,OpenAI,Moondream2,Size Measurement,Detections Stabilizer,Dominant Color,Microsoft SQL Server Sink,SIFT,Stability AI Outpainting,Dimension Collapse,Email Notification,ByteTrack Tracker,Classification Label Visualization,Bounding Box Visualization,Object Detection Model,Pixelate Visualization,Template Matching,Image Slicer,Roboflow Vision Events,Text Display,Distance Measurement,Time in Zone,Blur Visualization,Qwen3-VL,MoonshotAI Kimi,Detections List Roll-Up,LMM,Stability AI Inpainting,Roboflow Dataset Upload,PLC ModbusTCP,Qwen3.5-VL,Circle Visualization,Instance Segmentation Model,Label Visualization,Morphological Transformation,Polygon Zone Visualization,VLM As Classifier,OpenAI,CSV Formatter,Stability AI Image Generation,CogVLM,Roboflow Dataset Upload,Detections Merge,Clip Comparison,Triangle Visualization,Background Color Visualization,Detections Consensus,Stitch OCR Detections,Delta Filter,Line Counter Visualization,Halo Visualization,Roboflow Custom Metadata,OpenAI,Email Notification,Slack Notification,Llama 3.2 Vision,Detections Filter,Bounding Rectangle,Google Gemma API,Event Writer,Google Gemini,Rate Limiter,Ellipse Visualization,Inner Workflow,Image Contours,SAM 3,YOLO-World Model,Crop Visualization,Perception Encoder Embedding Model,SAM2 Video Tracker,Relative Static Crop,Semantic Segmentation Model,Object Detection Model,EasyOCR,VLM As Detector,SAM 3,Image Convert Grayscale,Qwen3.5,Google Gemma,Google Gemini,Image Blur,Identify Changes,MQTT Writer,Buffer,Anthropic Claude,OC-SORT Tracker,PTZ Tracking (ONVIF),SIFT Comparison,Detections Stitch,Overlap Analysis,Qwen 3.6 API,Semantic Segmentation Model,Detections Classes Replacement,SAM 3,Time in Zone,Mask Edge Snap,Contrast Equalization,SORT Tracker,Image Stack,Single-Label Classification Model,Identify Outliers,Dynamic Zone,Continue If,Reference Path Visualization,Polygon Visualization,QR Code Detection,Property Definition,Path Deviation,Webhook Sink,Instance Segmentation Model,Image Slicer,Halo Visualization,QR Code Generator,Local File Sink,MoonshotAI Kimi,SmolVLM2,Path Deviation,Depth Estimation,Byte Tracker,Object Detection Model,Icon Visualization,Motion Detection,VLM As Classifier,Anthropic Claude,Cosine Similarity,Grid Visualization,OpenRouter,Anthropic Claude,Model Monitoring Inference Aggregator,Image Threshold,Overlap Filter,Data Aggregator,Trace Visualization,Pixel Color Count,Morphological Transformation,Keypoint Detection Model,Dynamic Crop,Polygon Visualization,Florence-2 Model,Detections Transformation,Environment Secrets Store,Single-Label Classification Model,Gaze Detection,Qwen 3.5 API,Byte Tracker,Absolute Static Crop,Mask Area Measurement,Multi-Label Classification Model,Stitch Images,Florence-2 Model,Twilio SMS/MMS Notification,Line Counter,Time in Zone,Byte Tracker,Roboflow Asset Library Attributes,Keypoint Detection Model,Corner Visualization,Detections Combine,Stitch OCR Detections,BoT-SORT Tracker,OCR Model,Line Counter,S3 Sink,GLM-OCR,Detection Event Log,OpenAI,Qwen2.5-VL,Heatmap Visualization,Instance Segmentation Model,OPC UA Writer Sink,Per-Class Confidence Filter,Velocity - outputs:
Google Gemma API,Camera Focus,Event Writer,Google Gemini,Rate Limiter,Current Time,Ellipse Visualization,Camera Focus,Inner Workflow,Image Preprocessing,Background Subtraction,Multi-Label Classification Model,SAM 3,Image Contours,Color Visualization,Mask Visualization,Crop Visualization,Segment Anything 2 Model,YOLO-World Model,Seg Preview,Multi-Label Classification Model,Perception Encoder Embedding Model,SAM2 Video Tracker,JSON Parser,Cache Set,Google Vision OCR,Relative Static Crop,SIFT Comparison,Single-Label Classification Model,Object Detection Model,Semantic Segmentation Model,Google Gemini,Instance Segmentation Model,EasyOCR,Llama 3.2 Vision,VLM As Detector,SAM 3,Contrast Enhancement,Image Convert Grayscale,Qwen3.5,Google Gemma,Google Gemini,Keypoint Detection Model,Identify Changes,Keypoint Visualization,Image Blur,MQTT Writer,Buffer,Anthropic Claude,OC-SORT Tracker,First Non Empty Or Default,Camera Calibration,VLM As Detector,PTZ Tracking (ONVIF),SIFT Comparison,Twilio SMS Notification,Expression,Detections Stitch,LMM For Classification,Overlap Analysis,Qwen 3.6 API,Barcode Detection,Semantic Segmentation Model,Perspective Correction,Cache Get,Detections Classes Replacement,SAM 3,Time in Zone,Detection Offset,CLIP Embedding Model,Mask Edge Snap,OpenAI-Compatible LLM,Contrast Equalization,Clip Comparison,SORT Tracker,Qwen-VL,Image Stack,Model Comparison Visualization,Single-Label Classification Model,Identify Outliers,PLC EthernetIP,Dot Visualization,OpenAI,Dynamic Zone,Continue If,Moondream2,Reference Path Visualization,Polygon Visualization,Size Measurement,QR Code Detection,Detections Stabilizer,Dominant Color,Microsoft SQL Server Sink,Llama 3.2 Vision,Path Deviation,Property Definition,Webhook Sink,SIFT,Instance Segmentation Model,Image Slicer,Stability AI Outpainting,Halo Visualization,Dimension Collapse,Email Notification,QR Code Generator,Local File Sink,ByteTrack Tracker,Classification Label Visualization,Bounding Box Visualization,MoonshotAI Kimi,Object Detection Model,SmolVLM2,Pixelate Visualization,Path Deviation,Template Matching,Image Slicer,Depth Estimation,Roboflow Vision Events,Text Display,Byte Tracker,Time in Zone,Object Detection Model,Distance Measurement,Icon Visualization,Motion Detection,Blur Visualization,VLM As Classifier,Anthropic Claude,Grid Visualization,Qwen3-VL,OpenRouter,Cosine Similarity,Anthropic Claude,Detections List Roll-Up,MoonshotAI Kimi,LMM,Stability AI Inpainting,Roboflow Dataset Upload,PLC ModbusTCP,Qwen3.5-VL,Image Threshold,Overlap Filter,Model Monitoring Inference Aggregator,Data Aggregator,Trace Visualization,Circle Visualization,Instance Segmentation Model,Label Visualization,Pixel Color Count,Morphological Transformation,Morphological Transformation,Polygon Zone Visualization,Keypoint Detection Model,VLM As Classifier,Dynamic Crop,Polygon Visualization,Florence-2 Model,OpenAI,Detections Transformation,CSV Formatter,Single-Label Classification Model,Stability AI Image Generation,Gaze Detection,Qwen 3.5 API,Byte Tracker,Mask Area Measurement,Absolute Static Crop,CogVLM,Roboflow Dataset Upload,Multi-Label Classification Model,Stitch Images,Florence-2 Model,Twilio SMS/MMS Notification,Line Counter,Time in Zone,Detections Merge,Clip Comparison,Byte Tracker,Triangle Visualization,Roboflow Asset Library Attributes,Detections Consensus,Background Color Visualization,Keypoint Detection Model,Corner Visualization,Stitch OCR Detections,Delta Filter,Detections Combine,Line Counter Visualization,BoT-SORT Tracker,Stitch OCR Detections,Halo Visualization,Roboflow Custom Metadata,Line Counter,OCR Model,OpenAI,Email Notification,Slack Notification,S3 Sink,GLM-OCR,Detection Event Log,OpenAI,Qwen2.5-VL,Detections Filter,Heatmap Visualization,Bounding Rectangle,Instance Segmentation Model,OPC UA Writer Sink,Per-Class Confidence Filter,Velocity
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"
}