morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::VerifiedCache Class Reference

A content-addressed cache that hands out only bytes that hash to the hash they are asked for. More...

#include <service_client.hpp>

Public Member Functions

 VerifiedCache (std::shared_ptr< IBundleStore > store)
 A cache over store.
std::optional< std::string > get (std::string const &hash)
 Reads a file, verified. A stored file that does not hash to hash is dropped and reads as a miss.
std::string put (std::string bytes)
 Keeps a file under its content hash.
IBundleStore & store () noexcept
 The store.

Detailed Description

A content-addressed cache that hands out only bytes that hash to the hash they are asked for.

Definition at line 150 of file service_client.hpp.

Constructor & Destructor Documentation

◆ VerifiedCache()

morph::ui::VerifiedCache::VerifiedCache ( std::shared_ptr< IBundleStore > store)
inlineexplicit

A cache over store.

Parameters
storeThe store; shared with the caller.
Exceptions
std::invalid_argumentif store is null.

Definition at line 155 of file service_client.hpp.

Member Function Documentation

◆ get()

std::optional< std::string > morph::ui::VerifiedCache::get ( std::string const & hash)
inlinenodiscard

Reads a file, verified. A stored file that does not hash to hash is dropped and reads as a miss.

Parameters
hashThe content hash.
Returns
The bytes, or nothing.

Definition at line 164 of file service_client.hpp.

◆ put()

std::string morph::ui::VerifiedCache::put ( std::string bytes)
inline

Keeps a file under its content hash.

Parameters
bytesThe bytes.
Returns
The hash they are kept under.

Definition at line 177 of file service_client.hpp.

◆ store()

IBundleStore & morph::ui::VerifiedCache::store ( )
inlinenodiscardnoexcept

The store.

Returns
It.

Definition at line 185 of file service_client.hpp.


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