class Matter::Storage::JsonFileBackend

Overview

A simple JSON file backed storage implementation.

Persists the same context-key model as MemoryBackend to a single JSON file. This is intended as a low-friction default for devices/examples and as the foundation for future DB-backed implementations.

Defined in:

matter/storage/json_file_backend.cr

Constant Summary

TYPE_FIELD = "__type__"

Root JSON keys used to preserve non-JSON-native types

VALUE_FIELD = "value"

Constructors

Instance Method Summary

Instance methods inherited from class Matter::Storage::Base

clear : Nil clear, clear_all(contexts : Array(String)) : Nil clear_all, contexts(contexts : Array(String)) : Array(String) contexts, delete(contexts : Array(String), key : String) : Nil delete, get(contexts : Array(String), key : String) : Type get, initialized? : Bool initialized?, keys(contexts : Array(String)) : Array(String) keys, set(contexts : Array(String), key : String, value : Type) : Nil set, start : Nil start, stop : Nil stop, values(contexts : Array(String)) : Hash(String, Type) values

Constructor Detail

def self.new(path : String = "matter_storage.json") #

[View source]

Instance Method Detail

def clear : Nil #

Clears all stored contexts and keys.


[View source]
def clear_all(contexts : Array(String)) : Nil #

[View source]
def contexts(contexts : Array(String)) : Array(String) #

Get list of immediate subcontext names


[View source]
def delete(contexts : Array(String), key : String) : Nil #

[View source]
def get(contexts : Array(String), key : String) : Type #

[View source]
def initialized? : Bool #

[View source]
def keys(contexts : Array(String)) : Array(String) #

[View source]
def path : String #

[View source]
def set(contexts : Array(String), key : String, value : Type) : Nil #

[View source]
def set(contexts : Array(String), values : Hash(String, Type)) : Nil #

Set multiple key-value pairs at once


[View source]
def start : Nil #

[View source]
def stop : Nil #

[View source]
def values(contexts : Array(String)) : Hash(String, Type) #

Get all key-value pairs in a context


[View source]