88from __future__ import annotations
99
1010import asyncio
11- from enum import Enum
1211from typing import TYPE_CHECKING , Optional
1312
1413from marimo import _loggers
@@ -98,11 +97,6 @@ def _stop(self) -> None:
9897 self .heartbeat_task .cancel ()
9998
10099
101- class CacheMode (Enum ):
102- READ = "read"
103- READ_WRITE = "write"
104-
105-
106100class CachingExtension (SessionExtension , SessionEventListener ):
107101 """Extension for caching session state to disk.
108102
@@ -117,18 +111,15 @@ def __init__(
117111 * ,
118112 enabled : bool ,
119113 interval : int = SESSION_CACHE_INTERVAL_SECONDS ,
120- mode : CacheMode = CacheMode .READ_WRITE ,
121114 ) -> None :
122115 """Initialize the caching extension.
123116
124117 Args:
125118 enabled: Whether to enable caching
126119 interval: How often to write cache (in seconds)
127- mode: Whether to read cache only or read/write.
128120 """
129121 self .interval = interval
130122 self .enabled = enabled
131- self .mode = mode
132123 self .session_cache_manager : Optional [SessionCacheManager ] = None
133124 self .event_bus : Optional [SessionEventBus ] = None
134125
@@ -174,8 +165,7 @@ def on_attach(self, session: Session, event_bus: SessionEventBus) -> None:
174165 )
175166
176167 # Start the background task to write the session view to disk
177- if self .mode is CacheMode .READ_WRITE :
178- self .session_cache_manager .start ()
168+ self .session_cache_manager .start ()
179169
180170 def on_detach (self ) -> None :
181171 """Stop cache manager when detached."""
@@ -189,8 +179,6 @@ async def on_session_notebook_renamed(
189179 ) -> None :
190180 """Rename the path for the cache manager."""
191181 del old_path
192- if self .mode is not CacheMode .READ_WRITE :
193- return None
194182 path = session .app_file_manager .path
195183 if self .session_cache_manager and path :
196184 self .session_cache_manager .rename_path (path )
0 commit comments