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.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Cache Set in version v1.
- inputs:
Florence-2 Model,Detections Combine,Roboflow Dataset Upload,Trace Visualization,Delta Filter,Classification Label Visualization,Single-Label Classification Model,Line Counter,Clip Comparison,Ellipse Visualization,Qwen3-VL,Detections Stabilizer,Triangle Visualization,Morphological Transformation,Path Deviation,LMM,First Non Empty Or Default,SmolVLM2,Dimension Collapse,Local File Sink,Barcode Detection,VLM As Classifier,Icon Visualization,QR Code Generator,Stability AI Outpainting,OpenAI,Keypoint Detection Model,Moondream2,Florence-2 Model,Pixelate Visualization,Object Detection Model,Gaze Detection,Cosine Similarity,Clip Comparison,Background Color Visualization,Background Subtraction,Time in Zone,Keypoint Detection Model,Keypoint Visualization,Perception Encoder Embedding Model,Overlap Filter,EasyOCR,Image Blur,Anthropic Claude,Polygon Visualization,SIFT,Webhook Sink,Object Detection Model,Dominant Color,Cache Get,YOLO-World Model,Property Definition,Multi-Label Classification Model,Heatmap Visualization,Image Threshold,Google Gemini,Text Display,Detection Event Log,OpenAI,Instance Segmentation Model,Qwen2.5-VL,Continue If,Single-Label Classification Model,Anthropic Claude,Time in Zone,CSV Formatter,Path Deviation,Rate Limiter,Detections Consensus,Stability AI Inpainting,Roboflow Custom Metadata,QR Code Detection,Polygon Visualization,CogVLM,Velocity,Bounding Box Visualization,CLIP Embedding Model,Llama 3.2 Vision,Identify Outliers,Camera Focus,Email Notification,Dynamic Crop,Image Contours,Time in Zone,LMM For Classification,Buffer,Seg Preview,Segment Anything 2 Model,Stitch Images,Bounding Rectangle,Image Slicer,Line Counter,Byte Tracker,SAM 3,Distance Measurement,Roboflow Dataset Upload,Crop Visualization,Grid Visualization,Google Gemini,Stitch OCR Detections,Twilio SMS/MMS Notification,Reference Path Visualization,Multi-Label Classification Model,Data Aggregator,Image Slicer,Detections Classes Replacement,Detection Offset,Detections Transformation,Google Vision OCR,Camera Focus,Pixel Color Count,Model Comparison Visualization,Template Matching,Image Preprocessing,Twilio SMS Notification,Color Visualization,Polygon Zone Visualization,OpenAI,Halo Visualization,Instance Segmentation Model,Contrast Equalization,Byte Tracker,Mask Area Measurement,Google Gemini,Perspective Correction,Circle Visualization,Blur Visualization,Dot Visualization,Camera Calibration,Relative Static Crop,Email Notification,Depth Estimation,VLM As Detector,Mask Visualization,Dynamic Zone,Stability AI Image Generation,Detections Filter,Byte Tracker,Environment Secrets Store,Size Measurement,Halo Visualization,Absolute Static Crop,Detections Stitch,OCR Model,Label Visualization,Detections Merge,Motion Detection,Anthropic Claude,Stitch OCR Detections,Corner Visualization,Cache Set,Image Convert Grayscale,Expression,SIFT Comparison,SIFT Comparison,Detections List Roll-Up,SAM 3,VLM As Detector,Line Counter Visualization,SAM 3,VLM As Classifier,JSON Parser,PTZ Tracking (ONVIF),Slack Notification,Identify Changes,Model Monitoring Inference Aggregator,OpenAI - outputs:
Florence-2 Model,Detections Combine,Trace Visualization,Roboflow Dataset Upload,Delta Filter,Classification Label Visualization,Single-Label Classification Model,Line Counter,Clip Comparison,Ellipse Visualization,Qwen3-VL,Detections Stabilizer,Triangle Visualization,Path Deviation,Morphological Transformation,LMM,First Non Empty Or Default,SmolVLM2,Dimension Collapse,Barcode Detection,Local File Sink,VLM As Classifier,Icon Visualization,QR Code Generator,Stability AI Outpainting,OpenAI,Moondream2,Keypoint Detection Model,Florence-2 Model,Pixelate Visualization,Object Detection Model,Gaze Detection,Cosine Similarity,Clip Comparison,Background Color Visualization,Time in Zone,Background Subtraction,Keypoint Detection Model,Keypoint Visualization,Perception Encoder Embedding Model,Overlap Filter,EasyOCR,Image Blur,Polygon Visualization,Anthropic Claude,SIFT,Webhook Sink,Object Detection Model,Dominant Color,Cache Get,YOLO-World Model,Property Definition,Multi-Label Classification Model,Heatmap Visualization,Image Threshold,Google Gemini,Text Display,Detection Event Log,OpenAI,Instance Segmentation Model,Qwen2.5-VL,Continue If,Single-Label Classification Model,Anthropic Claude,Time in Zone,CSV Formatter,Path Deviation,Rate Limiter,Detections Consensus,Stability AI Inpainting,Roboflow Custom Metadata,QR Code Detection,Polygon Visualization,CogVLM,Velocity,Bounding Box Visualization,CLIP Embedding Model,Llama 3.2 Vision,Identify Outliers,Camera Focus,Email Notification,Dynamic Crop,Image Contours,Time in Zone,LMM For Classification,Buffer,Seg Preview,Segment Anything 2 Model,Stitch Images,Bounding Rectangle,Image Slicer,Line Counter,Byte Tracker,SAM 3,Distance Measurement,Crop Visualization,Roboflow Dataset Upload,Grid Visualization,Twilio SMS/MMS Notification,Multi-Label Classification Model,Stitch OCR Detections,Google Gemini,Reference Path Visualization,Image Slicer,Data Aggregator,Detections Classes Replacement,Detection Offset,Detections Transformation,Google Vision OCR,Pixel Color Count,Camera Focus,Model Comparison Visualization,Template Matching,Image Preprocessing,Twilio SMS Notification,Color Visualization,Polygon Zone Visualization,OpenAI,Halo Visualization,Instance Segmentation Model,Contrast Equalization,Byte Tracker,Mask Area Measurement,Google Gemini,Perspective Correction,Circle Visualization,Blur Visualization,Dot Visualization,Camera Calibration,Relative Static Crop,Email Notification,Depth Estimation,VLM As Detector,Mask Visualization,Stability AI Image Generation,Dynamic Zone,Detections Filter,Byte Tracker,Size Measurement,Halo Visualization,Absolute Static Crop,Detections Stitch,OCR Model,Label Visualization,Detections Merge,Motion Detection,Anthropic Claude,Stitch OCR Detections,Corner Visualization,Cache Set,Image Convert Grayscale,Expression,SIFT Comparison,SIFT Comparison,Detections List Roll-Up,SAM 3,VLM As Detector,Line Counter Visualization,SAM 3,VLM As Classifier,JSON Parser,PTZ Tracking (ONVIF),Slack Notification,Identify Changes,Model Monitoring Inference Aggregator,OpenAI
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"
}