Commit graph

115 commits

Author SHA1 Message Date
Eliah Rusin
06f01b3d7c
Refactor caching system to use pluggable stores (#98)
* Refactor caching system to use pluggable stores

The commit modernizes the caching implementation by introducing a pluggable store interface that allows different cache backends. Key changes:

- Add Store interface for custom cache implementations
- Create default TTL-based store for backwards compatibility
- Add example LRU store for memory-bounded caching
- Support cache store configuration via options pattern
- Make cache cleanup logic implementation-specific
- Add comprehensive tests and documentation

The main goals were to:

1. Prevent unbounded memory growth through pluggable stores
2. Enable distributed caching support
3. Maintain backwards compatibility
4. Improve testability and maintainability

Signed-off-by: franchb <hello@franchb.com>

* Add custom cache stores docs and navigation

Signed-off-by: franchb <hello@franchb.com>

* 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

* rename to WithCacheStore

---------

Signed-off-by: franchb <hello@franchb.com>
Co-authored-by: maddalax <jm@madev.me>
2025-07-03 14:07:16 -05:00
maddalax
0c84e42160 add info on how to change it 2025-01-06 10:26:15 -06:00
maddalax
4f537567ad allow port to be configured 2025-01-06 10:24:49 -06:00
maddalax
ef83e34b1e add RunAfterTimeout & RunOnInterval 2024-11-16 08:45:03 -06:00
maddalax
34e816ff7c
Websocket Extension - Alpha (#22)
* wip

* merge

* working again

* refactor/make it a bit cleaner

* fix to only call cb for session id who initiated the event

* support broadcasting events to all clients

* refactor

* refactor into ws extension

* add go mod

* rename module

* fix naming

* refactor

* rename

* merge

* fix manager ws delete, add manager tests

* add metric page

* fixes, add k6 script

* fixes, add k6 script

* deploy docker image

* cleanup

* cleanup

* cleanup
2024-11-09 12:05:53 -06:00
maddalax
2d6ab078be swap tests 2024-10-31 11:59:19 -05:00
maddalax
248e485ff0 ordered map tests, extensions test 2024-10-31 11:43:24 -05:00
maddalax
f42351e94f more tests 2024-10-31 11:36:57 -05:00
maddalax
8a00828232 conditional tests 2024-10-31 11:11:09 -05:00
maddalax
f6556b579f css form on blur validation 2024-10-31 09:44:16 -05:00
maddalax
35877a1b2e
New Docs (#63)
* scripting enhancements

* tests

* cleanup / tests

* new docs wip

* add more docs

* more updates

* add caching docs

* add sse docs

* more docs

* sidebar, and fix navigation blocks

* remove old docs

* set proper meta

* fixes
2024-10-30 13:27:42 -05:00
maddalax
d85737bfb8
JS Eval Enhancements (#62)
* scripting enhancements

* tests

* cleanup / tests
2024-10-29 08:44:52 -05:00
maddalax
cb012a4d82 cleanup usage of orderedmap
add tests
add groupby
add groupbyordered
2024-10-29 05:48:13 -05:00
maddalax
7666186f83 add inline edit / fix copy button 2024-10-28 18:47:00 -05:00
maddalax
b65a913d4e test more examples 2024-10-28 10:56:03 -05:00
maddalax
2726c60608 set charset on html content type 2024-10-26 21:41:21 -05:00
maddalax
3468baaa84 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	framework/h/attribute.go
#	framework/h/lifecycle.go
#	framework/h/render.go
2024-10-25 22:01:04 -05:00
maddalax
cf76ca4f98 add some comments 2024-10-25 21:59:17 -05:00
maddalax
61758622ef indent -> indentme
add details & summary html tag
2024-10-25 07:07:35 -05:00
maddalax
a72de0a62f add qs tests 2024-10-23 10:50:22 -05:00
maddalax
bb9fb0b327 write doctype when rendering html 2024-10-23 09:28:19 -05:00
Mohammad javad
30ac29fd6c
use path (#32)
* feat:add claasf

* refactor(tag.go)

* refactor(cache.go)

* refactor(attribute.go)

* refactor(app.go)

* refactor(attribute.go)

* fix:use path in PostPartialWithQs

* fix: PostPartial
2024-10-22 08:49:17 -05:00
Mohammad javad
a0f5b5dfd5
feat:add claasf (#31)
* feat:add claasf

* refactor(tag.go)

* refactor(cache.go)

* refactor(attribute.go)

* refactor(app.go)

* refactor(attribute.go)
2024-10-22 08:32:17 -05:00
maddalax
635b17dd7f add support for ignoring specific files for automatic page/partial routing 2024-10-21 10:06:18 -05:00
Kevin Lewin
cea6b1cff2
Update slog output for server start (#27)
Fixing f string error.
2024-10-21 09:17:18 -05:00
maddalax
b6d901fadf add some helper methods for redirect and setting cookie 2024-10-20 10:21:37 -05:00
maddalax
13f650b28b simple auth example 2024-10-20 07:48:19 -05:00
Kevin Lewin
a7110576d2
Update app.go (#24)
Reformat server listening log message so user could click from terminal or ide
2024-10-18 17:29:59 -05:00
maddalax
8b9e536f14 add converter to site 2024-10-11 11:19:32 -05:00
maddalax
ea5d4d5e2e update onload to always be called when element gets rendered again 2024-10-11 08:56:56 -05:00
maddalax
819af8b7b8 infinite scroll 2024-10-10 20:17:31 -05:00
maddalax
298f4dcd61 revert 2024-10-09 10:31:34 -05:00
maddalax
0b38bcaa21 Revert "websocket stuff wip"
This reverts commit 9f53e8b2
2024-10-09 10:30:14 -05:00
maddalax
f3cb95960c fix watcher to watch newly added dirs
add utility methods to RequestContext

Fix GetPartialPath
2024-10-09 10:28:41 -05:00
maddalax
9f53e8b2aa websocket stuff wip 2024-10-08 12:48:28 -05:00
maddalax
1014f6c961 add htmx to window
small swap fix
copy public assets to dist if changed
2024-10-07 12:57:24 -05:00
maddalax
805e5729e1 build fix 2024-10-04 11:21:15 -05:00
maddalax
e6af7a73d5 fix test 2024-10-03 15:41:09 -05:00
maddalax
496981efd0 fix tests 2024-10-03 15:35:19 -05:00
maddalax
8b816e9566 switch to sse 2024-10-01 22:26:03 -05:00
maddalax
5b10aed601 cleanup 2024-10-01 17:19:38 -05:00
maddalax
784995728c add error handling 2024-10-01 12:09:22 -05:00
maddalax
27b5de93ea chat working 2024-09-30 22:08:52 -05:00
maddalax
787ccb4fc1 entry page 2024-09-30 20:32:42 -05:00
maddalax
ae983473b3 db progress 2024-09-30 17:31:09 -05:00
maddalax
8cdc625133 some cleanup 2024-09-30 16:32:12 -05:00
maddalax
c7f4781137 spin up chat app, setup sockets, fix trigger children to work 2024-09-30 16:05:06 -05:00
maddalax
e5c5014812 more tests 2024-09-30 13:01:51 -05:00
maddalax
3c4583c2b3 cleanup 2024-09-30 12:47:10 -05:00
maddalax
7b83e2fde7 update attrs to use ordered map 2024-09-30 12:39:48 -05:00