memory/jsonl: add disk-backed Store with full CRUD, Compact, flock, and provider adapter

This commit is contained in:
sausheong committed 2026-05-09 06:54:07 +08:00
1 parent 1acf0d48a3
commit d2491dc90f
5 files changed
+828 -1

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
//go:build !windows
package jsonl
import (
"os"
"golang.org/x/sys/unix"
)
// lockExclusive acquires an exclusive (write) advisory lock on f.
// Blocks until the lock is available. Released when the file descriptor
// is closed (caller's defer f.Close() does this).
func lockExclusive(f *os.File) error {
return unix.Flock(int(f.Fd()), unix.LOCK_EX)
}
// lockShared acquires a shared (read) advisory lock on f. Multiple
// shared lockers can coexist; an exclusive locker blocks them.
func lockShared(f *os.File) error {
return unix.Flock(int(f.Fd()), unix.LOCK_SH)
}