C/C++ API Reference
Loading...
Searching...
No Matches
pw::kvs::KeyValueStore Class Reference

Overview

Flash-backed persistent key-value store (KVS) with integrated wear-leveling.

Instances are declared as instances of pw::kvs::KeyValueStoreBuffer<MAX_ENTRIES, MAX_SECTORS>, which allocates buffers for tracking entries and flash sectors.

#include "pw_kvs/key_value_store.h"
#include "pw_kvs/flash_test_partition.h"
constexpr size_t kMaxSectors = 6;
constexpr size_t kMaxEntries = 64;
static constexpr pw::kvs::EntryFormat kvs_format = {
.magic = 0xd253a8a9, // Prod apps should use a random number here
.checksum = nullptr
};
&pw::kvs::FlashTestPartition(),
kvs_format
);
kvs.Init();
Definition: key_value_store.h:702
Inheritance diagram for pw::kvs::KeyValueStore:
pw::kvs::KeyValueStoreBuffer< kMaxEntries, kMaxUsableSectors, kRedundancy, kEntryFormats >

Classes

class  Item
 Representation of a key-value entry during iteration. More...
 
class  iterator
 Supported iteration methods. More...
 
struct  StorageStats
 

Public Types

using const_iterator = iterator
 

Public Member Functions

Status Init ()
 
bool initialized () const
 
StatusWithSize Get (std::string_view key, span< std::byte > value, size_t offset_bytes=0) const
 
template<typename Pointer , typename = std::enable_if_t<std::is_pointer<Pointer>::value>>
Status Get (const std::string_view &key, const Pointer &pointer) const
 
template<typename T , typename std::enable_if_t< ConvertsToSpan< T >::value > * = nullptr>
Status Put (const std::string_view &key, const T &value)
 
template<typename T , typename std::enable_if_t<!ConvertsToSpan< T >::value > * = nullptr>
Status Put (const std::string_view &key, const T &value)
 
Status Delete (std::string_view key)
 
StatusWithSize ValueSize (std::string_view key) const
 
Status HeavyMaintenance ()
 
Status FullMaintenance ()
 
Status PartialMaintenance ()
 
void LogDebugInfo () const
 
iterator begin () const
 
iterator end () const
 
size_t size () const
 
size_t total_entries_with_deleted () const
 
size_t max_size () const
 
size_t empty () const
 
uint32_t transaction_count () const
 
StorageStats GetStorageStats () const
 
size_t redundancy () const
 
bool error_detected () const
 
size_t max_key_value_size_bytes () const
 
bool CheckForErrors ()
 

Static Public Member Functions

static constexpr size_t max_key_value_size_bytes (size_t partition_sector_size_bytes)
 

Protected Types

using Address = FlashPartition::Address
 
using Entry = internal::Entry
 
using KeyDescriptor = internal::KeyDescriptor
 
using SectorDescriptor = internal::SectorDescriptor
 

Protected Member Functions

 KeyValueStore (FlashPartition *partition, span< const EntryFormat > formats, const Options &options, size_t redundancy, Vector< SectorDescriptor > &sector_descriptor_list, const SectorDescriptor **temp_sectors_to_skip, Vector< KeyDescriptor > &key_descriptor_list, Address *addresses)
 

The documentation for this class was generated from the following file: