24#ifndef OPERATIONS_INCLUDED
25#define OPERATIONS_INCLUDED
481template <
typename Backend,
typename Data_extension = data::Data>
513 return !
cache_.store(metadata, secret_data);
528 Data_extension fetched_data;
529 if (!metadata.
valid())
return true;
530 if (!
cache_.get(metadata, fetched_data))
return true;
533 if ((*backend_).get(metadata, fetched_data))
return true;
553 Data_extension &data) {
554 if (!metadata.
valid())
return true;
555 if (!
cache_.get(metadata, data))
return true;
571 Data_extension stored_data(data);
572 if (!metadata.
valid())
return true;
573 Data_extension fetched_data;
574 if (
cache_.get(metadata, fetched_data))
return true;
575 if ((*backend_).store(metadata, stored_data))
return true;
592 if (!
cache_.store(metadata, stored_data)) {
594 (void)(*backend_).erase(metadata, stored_data);
610 if (!metadata.
valid())
return true;
611 Data_extension fetched_data;
613 if (!
cache_.get(metadata, fetched_data))
return true;
615 if ((*backend_).erase(metadata, fetched_data))
return true;
634 if (!metadata.
valid())
return true;
636 Data_extension generated_data(g_data);
637 if (
cache_.get(metadata, generated_data))
return true;
638 if ((*backend_).generate(metadata, generated_data,
length))
return true;
640 if (!
cache_.store(metadata, generated_data)) {
642 (void)(*backend_).erase(metadata, generated_data);
664 if (!
valid())
return true;
665 if (!metadata.
valid())
return true;
666 it = std::make_unique<iterator::Iterator<Data_extension>>(
cache_, metadata);
667 return (it.get() ==
nullptr);
682 if (!
valid())
return true;
683 it = std::make_unique<iterator::Iterator<Data_extension>>(
cache_,
cached);
684 return (it.get() ==
nullptr);
708 return (
valid() && it.get() !=
nullptr && (*it).valid(
cache_.version()));
721 if (
valid() && it.get() !=
nullptr)
return !((*it).next(
cache_.version()));
739 if (!
valid() || it.get() ==
nullptr || !(*it).valid(
cache_.version()))
741 if (!(*it).metadata(
cache_.version(), metadata))
return true;
743 if (!(*it).data(
cache_.version(), data))
return true;
745 cache_.get(metadata, data);
746 if ((*backend_).get(metadata, data))
return true;
748 return !metadata.
valid();
765 if (!
valid() || it.get() ==
nullptr || !(*it).valid(
cache_.version()))
767 if (!(*it).metadata(
cache_.version(), metadata))
return true;
768 if (!(*it).data(
cache_.version(), data))
return true;
770 return !metadata.
valid();
779 return (*backend_).maximum_data_length();
795 if (backend ==
nullptr || backend->size() == 0) {
800 if (backend->load_cache(*
this))
return;
806 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:482
bool erase(const meta::Metadata &metadata)
Remove API.
Definition: operations.h:609
bool next(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Move iterator forward.
Definition: operations.h:720
bool generate(const meta::Metadata &metadata, const data::Type type, size_t length)
Generate API.
Definition: operations.h:632
Keyring_operations(bool cache_data, Backend *backend)
Constructor.
Definition: operations.h:492
bool get_data_extension(const meta::Metadata &metadata, Data_extension &data)
Get Backend-specific data extension.
Definition: operations.h:552
bool store(const meta::Metadata &metadata, const data::Data &data)
Store API.
Definition: operations.h:570
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:736
size_t maximum_data_length() const
Maximum data length supported.
Definition: operations.h:778
bool init_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, bool cached)
Iterator creation.
Definition: operations.h:680
bool cache_data_
Flag to cache data.
Definition: operations.h:816
void deinit_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Iterator destruction.
Definition: operations.h:693
bool valid()
Validity.
Definition: operations.h:786
~Keyring_operations()=default
bool insert(const meta::Metadata &metadata, Data_extension secret_data)
Insert API to populate cache.
Definition: operations.h:509
bool is_valid(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Check iterator validity.
Definition: operations.h:707
void load_cache()
Definition: operations.h:789
bool init_read_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, const meta::Metadata &metadata)
Iterator creation for read.
Definition: operations.h:661
cache::Datacache< Data_extension > cache_
Metadata cache.
Definition: operations.h:814
std::unique_ptr< Backend > backend_
Keyring backend.
Definition: operations.h:818
size_t keyring_size()
Keyring size.
Definition: operations.h:783
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:762
bool get(const meta::Metadata &metadata, data::Data &data)
Search API.
Definition: operations.h:527
bool valid_
Validity.
Definition: operations.h:820
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:465
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:2440
required string type
Definition: replication_group_member_actions.proto:34
static double cached
Definition: xcom_statistics.cc:101