Returns the in-memory value for the given key.
node-persist's legacy getItem(key, callback) form throws, like every other removed API.
Optionaloptions: HAPFileStorageInitOptionsPersists the given value, replacing the file for this key atomically.
The value is written to a temporary file which is then renamed over the target, so an interrupted write
leaves the previous contents intact instead of a truncated file. This matters because a truncated
AccessoryInfo file reads back as an accessory which lost its pairings.
The in-memory value is only replaced once the new one reached the disk, so a failed write cannot leave an accessory which reads as paired now and unpaired after a restart.
Minimal synchronous file storage, a drop-in replacement for the subset of
node-persist@0.0.12which HAP-NodeJS used:initSync,getItem,setItemSyncandremoveItemSync.The on-disk layout is kept byte-for-byte compatible with node-persist 0.0.12: one file per key inside the storage directory, named after the raw key (no hashing or escaping), containing the bare
JSON.stringifyrepresentation of the value. Values are read once at initSync and served from memory afterwards.Keys must therefore be plain filenames: one which names a subdirectory, escapes the storage directory or starts with a dot is rejected rather than written somewhere it could never be read back from.
Writes are atomic, which node-persist's were not: see setItemSync.