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