htmgo/framework/h
franchb cfcfe7cb21
Use GetOrCompute for atomic cache access
The commit introduces an atomic GetOrCompute method to the cache interface and refactors all cache implementations to use it. This prevents race conditions and duplicate computations when multiple goroutines request the same uncached key simultaneously.

The changes eliminate a time-of-check to time-of-use race condition in the original caching implementation, where separate Get/Set operations could lead to duplicate renders under high concurrency.

With GetOrCompute, the entire check-compute-store operation happens atomically while holding the lock, ensuring only one goroutine computes a value for any given key.

The API change is backwards compatible as the framework handles the GetOrCompute logic internally. Existing applications will automatically benefit from the
2025-07-03 17:46:09 +03:00
..
cache Use GetOrCompute for atomic cache access 2025-07-03 17:46:09 +03:00
app.go add info on how to change it 2025-01-06 10:26:15 -06:00
array.go cleanup usage of orderedmap 2024-10-29 05:48:13 -05:00
array_test.go cleanup usage of orderedmap 2024-10-29 05:48:13 -05:00
attribute.go Websocket Extension - Alpha (#22) 2024-11-09 12:05:53 -06:00
attribute_test.go more tests 2024-10-31 11:36:57 -05:00
base.go css form on blur validation 2024-10-31 09:44:16 -05:00
base_test.go swap tests 2024-10-31 11:59:19 -05:00
cache.go Use GetOrCompute for atomic cache access 2025-07-03 17:46:09 +03:00
cache_integration_test.go Refactor caching system to use pluggable stores 2025-06-26 21:38:38 +03:00
command_test.go add RunAfterTimeout & RunOnInterval 2024-11-16 08:45:03 -06:00
conditionals.go add some comments 2024-10-25 21:59:17 -05:00
conditionals_test.go conditional tests 2024-10-31 11:11:09 -05:00
env.go add ent for sql 2024-09-17 10:41:29 -05:00
extensions.go Revert "websocket stuff wip" 2024-10-09 10:30:14 -05:00
extensions_test.go ordered map tests, extensions test 2024-10-31 11:43:24 -05:00
header.go Revert "websocket stuff wip" 2024-10-09 10:30:14 -05:00
header_test.go more tests 2024-10-31 11:36:57 -05:00
lifecycle.go add RunAfterTimeout & RunOnInterval 2024-11-16 08:45:03 -06:00
livereload.go swap out echo with std lib 2024-09-26 14:41:46 -05:00
qs.go Merge remote-tracking branch 'origin/master' 2024-10-25 22:01:04 -05:00
qs_test.go more tests 2024-10-31 11:36:57 -05:00
render.go Merge remote-tracking branch 'origin/master' 2024-10-25 22:01:04 -05:00
render_test.go Use GetOrCompute for atomic cache access 2025-07-03 17:46:09 +03:00
renderables.go update attrs to use ordered map 2024-09-30 12:39:48 -05:00
renderer.go JS Eval Enhancements (#62) 2024-10-29 08:44:52 -05:00
serialize.go more tests 2024-10-31 11:36:57 -05:00
serialize_test.go more tests 2024-10-31 11:36:57 -05:00
swap.go add htmx to window 2024-10-07 12:57:24 -05:00
swap_test.go more tests 2024-10-31 11:36:57 -05:00
tag.go Websocket Extension - Alpha (#22) 2024-11-09 12:05:53 -06:00
tag_test.go more tests 2024-10-31 11:36:57 -05:00
xhr.go Merge remote-tracking branch 'origin/master' 2024-10-25 22:01:04 -05:00
xhr_test.go swap tests 2024-10-31 11:59:19 -05:00