aboutsummaryrefslogtreecommitdiffstats
path: root/encoding.go
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.go')
-rw-r--r--encoding.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/encoding.go b/encoding.go
index ff07d2d..bd2d4b7 100644
--- a/encoding.go
+++ b/encoding.go
@@ -140,6 +140,8 @@ func (s *Store) Snapshot(w io.WriteSeeker) error {
w.Seek(0, io.SeekStart)
wr := NewEncoder(w)
+ wr.EncodeUint64(s.maxCost)
+ wr.EncodeUint64(uint64(s.strategy.Type))
wr.EncodeUint64(s.lenght)
for v := s.evict.EvictNext; v != &s.evict; v = v.EvictNext {
@@ -155,6 +157,18 @@ func (s *Store) LoadSnapshot(r io.ReadSeeker) error {
r.Seek(0, io.SeekStart)
rr := NewDecoder(r)
+ maxCost, err := rr.DecodeUint64()
+ if err != nil {
+ return err
+ }
+ s.maxCost = maxCost
+
+ policy, err := rr.DecodeUint64()
+ if err != nil {
+ return err
+ }
+ s.strategy.SetPolicy(EvictionPolicyType(policy))
+
lenght, err := rr.DecodeUint64()
if err != nil {
return err