Module: Philiprehberger::CacheKit::Serializable

Included in:
Store
Defined in:
lib/philiprehberger/cache_kit/serializable.rb

Overview

Snapshot and restore support for Store.

Instance Method Summary collapse

Instance Method Details

#restore(data) ⇒ void

This method returns an undefined value.

Restore cache state from a previous snapshot.

Parameters:

  • data (Hash)

    snapshot data from #snapshot



18
19
20
# File 'lib/philiprehberger/cache_kit/serializable.rb', line 18

def restore(data)
  @mutex.synchronize { apply_snapshot(data) }
end

#snapshotHash

Serialize current cache state for persistence.

Returns:

  • (Hash)

    serialized cache data



10
11
12
# File 'lib/philiprehberger/cache_kit/serializable.rb', line 10

def snapshot
  @mutex.synchronize { build_snapshot }
end