Skip to content

feat: add contrib.activity_cache for activity memoization#1376

Draft
saeedseyfi wants to merge 2 commits intotemporalio:mainfrom
saeedseyfi:contrib/activity-cache
Draft

feat: add contrib.activity_cache for activity memoization#1376
saeedseyfi wants to merge 2 commits intotemporalio:mainfrom
saeedseyfi:contrib/activity-cache

Conversation

@saeedseyfi
Copy link

Summary

  • Adds temporalio.contrib.activity_cache module for content-addressed activity memoization with shared remote storage
  • @cached decorator for explicit per-activity caching, CachingInterceptor for transparent all-activity caching
  • Custom key_fn for selecting which arguments matter for the cache key
  • Uses fsspec for storage (same approach as feat: add contrib.workdir for remote-backed activity workspaces #1375)

Closes #1374

Test plan

  • Unit tests for cache keys, serializers, decorator with memory:// backend
  • CI passes (lint, type checks, tests)

Activities aren't idempotent by default. When workflows retry or re-run,
every activity executes again even when inputs haven't changed. This module
provides content-addressed caching with shared remote storage via fsspec,
as both a decorator and an interceptor.

Closes temporalio#1374
@CLAassistant
Copy link

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

Tests interceptor with real Temporal worker:
- Verifies second call with same args is served from cache
- Verifies @no_cache activities always execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: contrib.activity_cache — Activity memoization with shared storage

2 participants