Loading...
Searching...
No Matches
storage.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <map>
23#include <string>
24#include <vector>
25
26namespace resdb {
27
28class Storage {
29 public:
30 Storage() = default;
31 virtual ~Storage() = default;
32
33 virtual int SetValue(const std::string& key, const std::string& value) = 0;
34 virtual std::string GetValue(const std::string& key) = 0;
35 virtual std::string GetAllValues() = 0;
36 virtual std::string GetRange(const std::string& min_key,
37 const std::string& max_key) = 0;
38
39 virtual int SetValueWithVersion(const std::string& key,
40 const std::string& value, int version) = 0;
41 virtual std::pair<std::string, int> GetValueWithVersion(
42 const std::string& key, int version) = 0;
43
44 // Return a map of <key, <value, version>>
45 virtual std::map<std::string, std::pair<std::string, int>> GetAllItems() = 0;
46 virtual std::map<std::string, std::pair<std::string, int>> GetKeyRange(
47 const std::string& min_key, const std::string& max_key) = 0;
48
49 // Return a list of <value, version> from a key
50 // The version list is sorted by the version value in descending order
51 virtual std::vector<std::pair<std::string, int>> GetHistory(
52 const std::string& key, int min_version, int max_version) = 0;
53
54 virtual std::vector<std::pair<std::string, int>> GetTopHistory(
55 const std::string& key, int number) = 0;
56
57 virtual bool Flush() { return true; };
58};
59
60} // namespace resdb
Storage()=default
virtual std::vector< std::pair< std::string, int > > GetTopHistory(const std::string &key, int number)=0
virtual std::vector< std::pair< std::string, int > > GetHistory(const std::string &key, int min_version, int max_version)=0
virtual int SetValueWithVersion(const std::string &key, const std::string &value, int version)=0
virtual int SetValue(const std::string &key, const std::string &value)=0
virtual bool Flush()
Definition storage.h:57
virtual std::string GetRange(const std::string &min_key, const std::string &max_key)=0
virtual ~Storage()=default
virtual std::string GetAllValues()=0
virtual std::string GetValue(const std::string &key)=0
virtual std::map< std::string, std::pair< std::string, int > > GetAllItems()=0
virtual std::map< std::string, std::pair< std::string, int > > GetKeyRange(const std::string &min_key, const std::string &max_key)=0
virtual std::pair< std::string, int > GetValueWithVersion(const std::string &key, int version)=0