Skip to content

Commit

Permalink
Create PMLL.h
Browse files Browse the repository at this point in the history
The persistent memory logic loop

Signed-off-by: J. K. Edwards <joed6834@colorado.edu>
  • Loading branch information
bearycool11 authored Jan 27, 2025
1 parent 911d2aa commit 682ffd2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions PMLL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef PMLL_H
#define PMLL_H

#include <string>
#include <unordered_map>
#include <fstream>
#include <iostream>
#include <mutex>

class PMLL {
private:
std::unordered_map<std::string, std::string> memory; // Key-value memory store
std::string memory_file; // File to store persistent memory
std::mutex memory_mutex; // Thread safety

void loadMemory(); // Load memory from the file
void saveMemory(); // Save memory to the file

public:
PMLL(const std::string& file_name); // Constructor
~PMLL(); // Destructor

void addMemory(const std::string& key, const std::string& value); // Add or update memory
std::string getMemory(const std::string& key) const; // Retrieve memory by key
void clearMemory(); // Clear all memory
void displayMemory() const; // Display all memory (debugging)
};

#endif // PMLL_H

0 comments on commit 682ffd2

Please sign in to comment.