24#ifndef OPERATIONS_INCLUDED
25#define OPERATIONS_INCLUDED
480template <
typename Backend,
typename Data_extension = data::Data>
512 return !
cache_.store(metadata, secret_data);
527 Data_extension fetched_data;
528 if (!metadata.
valid())
return true;
529 if (!
cache_.get(metadata, fetched_data))
return true;
532 if ((*backend_).get(metadata, fetched_data))
return true;
552 Data_extension &data) {
553 if (!metadata.
valid())
return true;
554 if (!
cache_.get(metadata, data))
return true;
570 Data_extension stored_data(data);
571 if (!metadata.
valid())
return true;
572 Data_extension fetched_data;
573 if (
cache_.get(metadata, fetched_data))
return true;
574 if ((*backend_).store(metadata, stored_data))
return true;
591 if (!
cache_.store(metadata, stored_data)) {
593 (void)(*backend_).erase(metadata, stored_data);
609 if (!metadata.
valid())
return true;
610 Data_extension fetched_data;
612 if (!
cache_.get(metadata, fetched_data))
return true;
614 if ((*backend_).erase(metadata, fetched_data))
return true;
633 if (!metadata.
valid())
return true;
635 Data_extension generated_data(g_data);
636 if (
cache_.get(metadata, generated_data))
return true;
637 if ((*backend_).generate(metadata, generated_data,
length))
return true;
639 if (!
cache_.store(metadata, generated_data)) {
641 (void)(*backend_).erase(metadata, generated_data);
663 if (!
valid())
return true;
664 if (!metadata.
valid())
return true;
665 it = std::make_unique<iterator::Iterator<Data_extension>>(
cache_, metadata);
666 return (it.get() ==
nullptr);
681 if (!
valid())
return true;
682 it = std::make_unique<iterator::Iterator<Data_extension>>(
cache_,
cached);
683 return (it.get() ==
nullptr);
707 return (
valid() && it.get() !=
nullptr && (*it).valid(
cache_.version()));
720 if (
valid() && it.get() !=
nullptr)
return !((*it).next(
cache_.version()));
738 if (!
valid() || it.get() ==
nullptr || !(*it).valid(
cache_.version()))
740 if (!(*it).metadata(
cache_.version(), metadata))
return true;
742 if (!(*it).data(
cache_.version(), data))
return true;
744 cache_.get(metadata, data);
745 if ((*backend_).get(metadata, data))
return true;
747 return !metadata.
valid();
764 if (!
valid() || it.get() ==
nullptr || !(*it).valid(
cache_.version()))
766 if (!(*it).metadata(
cache_.version(), metadata))
return true;
767 if (!(*it).data(
cache_.version(), data))
return true;
769 return !metadata.
valid();
778 return (*backend_).maximum_data_length();
794 if (backend ==
nullptr || backend->size() == 0) {
799 if (backend->load_cache(*
this))
return;
805 if (backend->size() !=
cache_.size()) {
Sensitive data storage.
Definition: data.h:39
virtual Data get_data() const
Return self.
Definition: data.cc:65
Definition: iterator.h:32
Keyring operations A class to perform operations on keyring.
Definition: operations.h:481
bool erase(const meta::Metadata &metadata)
Remove API.
Definition: operations.h:608
bool next(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Move iterator forward.
Definition: operations.h:719
bool generate(const meta::Metadata &metadata, const data::Type type, size_t length)
Generate API.
Definition: operations.h:631
Keyring_operations(bool cache_data, Backend *backend)
Constructor.
Definition: operations.h:491
bool get_data_extension(const meta::Metadata &metadata, Data_extension &data)
Get Backend-specific data extension.
Definition: operations.h:551
bool store(const meta::Metadata &metadata, const data::Data &data)
Store API.
Definition: operations.h:569
bool get_iterator_data(std::unique_ptr< iterator::Iterator< Data_extension > > &it, meta::Metadata &metadata, Data_extension &data)
Get data from iterator.
Definition: operations.h:735
size_t maximum_data_length() const
Maximum data length supported.
Definition: operations.h:777
bool init_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, bool cached)
Iterator creation.
Definition: operations.h:679
bool cache_data_
Flag to cache data.
Definition: operations.h:815
void deinit_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Iterator destruction.
Definition: operations.h:692
bool valid()
Validity.
Definition: operations.h:785
~Keyring_operations()=default
bool insert(const meta::Metadata &metadata, Data_extension secret_data)
Insert API to populate cache.
Definition: operations.h:508
bool is_valid(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Check iterator validity.
Definition: operations.h:706
void load_cache()
Definition: operations.h:788
bool init_read_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, const meta::Metadata &metadata)
Iterator creation for read.
Definition: operations.h:660
cache::Datacache< Data_extension > cache_
Metadata cache.
Definition: operations.h:813
std::unique_ptr< Backend > backend_
Keyring backend.
Definition: operations.h:817
size_t keyring_size()
Keyring size.
Definition: operations.h:782
bool get_iterator_metadata(std::unique_ptr< iterator::Iterator< Data_extension > > &it, meta::Metadata &metadata, Data_extension &data)
Get metadata from iterator.
Definition: operations.h:761
bool get(const meta::Metadata &metadata, data::Data &data)
Search API.
Definition: operations.h:526
bool valid_
Validity.
Definition: operations.h:819
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
std::string Type
Data types.
Definition: data.h:32
Definition: operations.h:464
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2439
required string type
Definition: replication_group_member_actions.proto:34
static double cached
Definition: xcom_statistics.cc:101