Skip to content

Commit 0ca21ec

Browse files
Merge pull request #522 from permaweb/fix/allow-process-cache-scoping
Fix/allow process cache scoping
2 parents 7f39f4a + f7c45d3 commit 0ca21ec

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/dev_process_cache.erl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ path(ProcID, Ref, PathSuffix, Opts) ->
6666
latest(ProcID, Opts) -> latest(ProcID, [], Opts).
6767
latest(ProcID, RequiredPath, Opts) ->
6868
latest(ProcID, RequiredPath, undefined, Opts).
69-
latest(ProcID, RawRequiredPath, Limit, Opts) ->
70-
?event(
71-
{latest_called,
72-
{proc_id, ProcID},
73-
{required_path, RawRequiredPath},
74-
{limit, Limit}
75-
}
76-
),
69+
latest(ProcID, RawRequiredPath, Limit, RawOpts) ->
70+
Scope = hb_opts:get(process_cache_scope, local, RawOpts),
71+
% Normalize the store descriptor to a list of stores.
72+
UnscopedStore =
73+
case hb_opts:get(store, no_viable_store, RawOpts) of
74+
StoreMsg when is_map(StoreMsg) -> [StoreMsg];
75+
Other -> Other
76+
end,
77+
% Apply the scope to the store and update the options message.
78+
ScopedStore = hb_store:scope(UnscopedStore, Scope),
79+
Opts = RawOpts#{ store => ScopedStore },
7780
% Convert the required path to a list of _binary_ keys.
7881
RequiredPath =
7982
case RawRequiredPath of

0 commit comments

Comments
 (0)