-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea0f192
commit dc1c9fd
Showing
15 changed files
with
985 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
#include "in_memory_text_storage.h" | ||
|
||
int InMemoryTextStorage::put(const std::string &text) | ||
{ | ||
storage_[next_key] = text; | ||
return next_key++; | ||
} | ||
|
||
const std::string &InMemoryTextStorage::get(int key) { return storage_[key]; } | ||
|
||
void InMemoryTextStorage::remove(int key) { storage_.erase(key); } | ||
|
||
InMemoryTextStorage g_mem_text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
|
||
/** | ||
* @brief 用于存放超长数据 | ||
* | ||
*/ | ||
|
||
class InMemoryTextStorage | ||
{ | ||
public: | ||
/** | ||
* @brief 用于存储超长数据 | ||
* | ||
* @param text 要存储的text | ||
* @return int 返回的键 | ||
*/ | ||
int put(const std::string& text); | ||
|
||
const std::string &get(int key); | ||
|
||
void remove(int key); | ||
|
||
private: | ||
int next_key = 0; | ||
std::unordered_map<int, std::string> storage_; | ||
}; | ||
|
||
extern InMemoryTextStorage g_mem_text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.