@@ -2218,7 +2218,7 @@ End
22182218/// - One for each entrySourceType, mapped via EntrySourceTypeMapper()
22192219threadsafe Function/WAVE GetLBRowCache ( WAVE values)
22202220
2221- variable actual, sweepNo, first, last
2221+ variable actual, sweepNo, first, last, expected
22222222 string key
22232223
22242224 variable versionOfNewWave = 6
@@ -2229,32 +2229,41 @@ threadsafe Function/WAVE GetLBRowCache(WAVE values)
22292229 WAVE /Z/ D wv = CA_TryFetchingEntryFromCache ( key, options = CA_OPTS_NO_DUPLICATE)
22302230
22312231 if ( ExistsWithCorrectLayoutVersion ( wv, versionOfNewWave))
2232- if ( actual == GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT))
2232+ expected = GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT)
2233+
2234+ // wave modification count tracking is only reliable while running
2235+ // inside a single experiment, not across experiments
2236+ if ( actual == expected)
22332237 return wv
22342238 elseif ( ! MU_RunningInMainThread () && GetLockState ( values) == 1 )
22352239 return wv
22362240 else
2237- // new entries were added so we need to propagate all entries to LABNOTEBOOK_GET_RANGE
2238- // for sweep numbers >= than the currently acquired sweep
2239- // this is required as the `last` element of the range can be changed if you add labnotebook
2240- // entries and then query them and then add again.
2241-
2242- if ( IsNumericWave ( values))
2243- WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2244- elseif ( IsTextWave ( values))
2245- WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2246- endif
2247-
2248- if ( IsFinite ( sweepNo))
2249- EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_GET_RANGE)
2250- first = limit ( sweepNo - 1, 0, Inf )
2251- last = sweepNo
2252- Multithread wv[ first, last][][] = LABNOTEBOOK_GET_RANGE
2253-
2254- // now we are up to date
2255- SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2256-
2257- return wv
2241+ if ( actual > expected)
2242+ // new entries were added so we need to propagate all entries to LABNOTEBOOK_GET_RANGE
2243+ // for sweep numbers >= than the currently acquired sweep
2244+ // this is required as the `last` element of the range can be changed if you add labnotebook
2245+ // entries and then query them and then add again.
2246+
2247+ if ( IsNumericWave ( values))
2248+ WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2249+ elseif ( IsTextWave ( values))
2250+ WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2251+ endif
2252+
2253+ if ( IsFinite ( sweepNo))
2254+ EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_GET_RANGE)
2255+ first = limit ( sweepNo - 1, 0, Inf )
2256+ last = sweepNo
2257+ Multithread wv[ first, last][][] = LABNOTEBOOK_GET_RANGE
2258+
2259+ // now we are up to date
2260+ SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2261+
2262+ return wv
2263+ endif
2264+ else
2265+ // cache across experiments, so the stored wave modification is
2266+ // larger than the last labnotebook we cached, go for a full reset
22582267 endif
22592268 endif
22602269 else
@@ -2293,7 +2302,7 @@ End
22932302/// could not be found, and #LABNOTEBOOK_UNCACHED_VALUE if the cache is empty.
22942303threadsafe Function/WAVE GetLBIndexCache ( WAVE values)
22952304
2296- variable actual, sweepNo, first, last
2305+ variable actual, sweepNo, first, last, expected
22972306 string key
22982307
22992308 variable versionOfNewWave = 5
@@ -2304,30 +2313,39 @@ threadsafe Function/WAVE GetLBIndexCache(WAVE values)
23042313 WAVE /Z/ D wv = CA_TryFetchingEntryFromCache ( key, options = CA_OPTS_NO_DUPLICATE)
23052314
23062315 if ( ExistsWithCorrectLayoutVersion ( wv, versionOfNewWave))
2307- if ( actual == GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT))
2316+ expected = GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT)
2317+
2318+ // wave modification count tracking is only reliable while running
2319+ // inside a single experiment, not across experiments
2320+ if ( actual == expected)
23082321 return wv
23092322 elseif ( ! MU_RunningInMainThread () && GetLockState ( values) == 1 )
23102323 return wv
23112324 else
2312- // new entries were added so we need to propagate all entries to uncached values
2313- // for sweep numbers >= than the currently acquired sweep
2314-
2315- if ( IsNumericWave ( values))
2316- WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2317- elseif ( IsTextWave ( values))
2318- WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2319- endif
2320-
2321- if ( IsFinite ( sweepNo))
2322- EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_UNCACHED_VALUE)
2323- first = limit ( sweepNo - 1, 0, Inf )
2324- last = sweepNo
2325- Multithread wv[ first, last][][] = LABNOTEBOOK_UNCACHED_VALUE
2326-
2327- // now we are up to date
2328- SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2329-
2330- return wv
2325+ if ( actual > expected)
2326+ // new entries were added so we need to propagate all entries to uncached values
2327+ // for sweep numbers >= than the currently acquired sweep
2328+
2329+ if ( IsNumericWave ( values))
2330+ WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2331+ elseif ( IsTextWave ( values))
2332+ WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2333+ endif
2334+
2335+ if ( IsFinite ( sweepNo))
2336+ EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_UNCACHED_VALUE)
2337+ first = limit ( sweepNo - 1, 0, Inf )
2338+ last = sweepNo
2339+ Multithread wv[ first, last][][] = LABNOTEBOOK_UNCACHED_VALUE
2340+
2341+ // now we are up to date
2342+ SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2343+
2344+ return wv
2345+ endif
2346+ else
2347+ // cache across experiments, so the stored wave modification is
2348+ // larger than the last labnotebook we cached, go for a full reset
23312349 endif
23322350 endif
23332351 else
0 commit comments