@@ -107,11 +107,13 @@ modules.
107107
108108Represents where data should be persisted, if anywhere.
109109
110- - If this is ` undefined ` or ` false ` , data will be stored in-memory and only
110+ - If this is ` undefined ` , it defaults to ` true ` if ` defaultPersistRoot ` is set
111+ or otherwise defaults to ` false ` .
112+ - If this is` false ` , data will be stored in-memory and only
111113 persist between ` Miniflare#setOptions() ` calls, not restarts nor
112114 ` new Miniflare ` instances.
113- - If this is ` true ` , data will be stored on the file-system, in the ` $PWD/.mf `
114- directory .
115+ - If this is ` true ` , data will be stored in a subdirectory of the ` defaultPersistRoot ` path if ` defaultPersistRoot ` is set
116+ or otherwise will be stored in a subdirectory of ` $PWD/.mf ` .
115117- If this looks like a URL, then:
116118 - If the protocol is ` memory: ` , data will be stored in-memory as above.
117119 - If the protocol is ` file: ` , data will be stored on the file-system, in the
@@ -490,6 +492,29 @@ parameter in module format Workers.
490492 as deployed Workers. If no routes match, Miniflare will fallback to the Worker
491493 defined first.
492494
495+ - ` defaultPersistRoot?: string `
496+
497+ Specifies the default directory where Miniflare will write persisted data when persistence is enabled.
498+
499+ ``` js
500+ // Without `defaultPersistRoot`
501+ new Miniflare ({
502+ kvPersist: undefined , // → "/(tmp)/kv"
503+ d1Persist: true , // → "$PWD/.mf/d1"
504+ r2Persist: false , // → "/(tmp)/r2"
505+ cachePersist: " /my-cache" , // → "/my-cache"
506+ });
507+
508+ // With `defaultPersistRoot`
509+ new Miniflare ({
510+ defaultPersistRoot: " /storage" ,
511+ kvPersist: undefined , // → "/storage/kv"
512+ d1Persist: true , // → "/storage/d1"
513+ r2Persist: false , // → "/(tmp)/r2"
514+ cachePersist: " /my-cache" , // → "/my-cache"
515+ });
516+ ```
517+
493518#### Cache
494519
495520- ` cache?: boolean `
0 commit comments