Skip to content

Commit 2a7e2ee

Browse files
committed
Add Offset method to Decoder for caching support
The Offset() method returns the current database offset position, enabling custom unmarshalers to implement caching based on data location. This addresses performance needs in applications that load databases with duplicate data structures.
1 parent 30c2d94 commit 2a7e2ee

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes
22

3+
## 2.0.0-beta.5
4+
5+
- Added `Offset()` method to `Decoder` to get the current database offset. This
6+
enables custom unmarshalers to implement caching for improved performance when
7+
loading databases with duplicate data structures.
8+
39
## 2.0.0-beta.4 - 2025-07-05
410

511
- **BREAKING CHANGE**: Removed experimental `deserializer` interface and

internal/decoder/decoder.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ func (d *Decoder) PeekKind() (Kind, error) {
351351
return kindNum, nil
352352
}
353353

354+
// Offset returns the current offset position in the database.
355+
// This can be used by custom unmarshalers for caching purposes.
356+
func (d *Decoder) Offset() uint {
357+
return d.offset
358+
}
359+
354360
func (d *Decoder) reset(offset uint) {
355361
d.offset = offset
356362
d.hasNextOffset = false

0 commit comments

Comments
 (0)