https://github.com/pierrekieffer/mstore
In-memory storage management system for embedded data storage
https://github.com/pierrekieffer/mstore
cache-storage embedded-database in-memory-caching in-memory-database in-memory-storage
Last synced: 27 days ago
JSON representation
In-memory storage management system for embedded data storage
- Host: GitHub
- URL: https://github.com/pierrekieffer/mstore
- Owner: PierreKieffer
- License: bsd-2-clause
- Created: 2020-06-10T08:42:57.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-17T17:16:46.000Z (over 4 years ago)
- Last Synced: 2024-06-19T04:17:11.309Z (10 months ago)
- Topics: cache-storage, embedded-database, in-memory-caching, in-memory-database, in-memory-storage
- Language: Go
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mstore
![]()

In-memory storage management system for embedded data storage.
As an example of application, mstore can be used as the core of a cache system, or simply as an embedded database.
mstore uses an indexing system to optimize operations performance.
mstore can manage multiple documents on the same index, but it is not possible to have several documents with the same key (the key is unique and is used to reference a document).+-------+ data memory slot
| | +--------+-----------+
index | | | | |
+-------> memory | Index +----------->+ Key_i | Data |
| slot | 01 | | | |
| | | +--------+-----------+
| +-------+
| | |
| | |
| | |
+-----------+ | | |
| | | | |
| Data +----------------+ +-------+
| | hash function | | +--------+-----------+ +--------+----------+
+-----------+ | | | | | | | |
| Index +----------->+ Key_j | Data +------------>+ Key_k | Data |
| .. | | | | | | |
| | +--------+-----------+ +--------+----------+
+-------+
| |
| |
| |
| |
| |
+-------+
| |
| |
| |
+ +## Download
```bash
go get github.com/PierreKieffer/mstore
```
## Usage```go
import(
"github.com/PierreKieffer/mstore"
)
```
### Initialize storage```go
s := mstore.InitStorage()
```
By default, the storage is built with 1000 indexes,It is possible to configure the maximum number of indexes that make up the storage
```go
s := mstore.InitStorage(10)
```### Document type
mstore uses a Document type :``` go
type Document struct {
Key string
Data interface{}
}
```
Documents are referenced by document key which must be unique.If no custom key is passed, a key is generated in UnixNano format.
### Insert
```go
var data interface{}
document := mstore.Document{Key: "custom-key", Data: data}
err = mstore.Insert(s, document)
if err != nil {
fmt.Println(err)
}
```### Update
```go
err = mstore.Update(s, document)
if err != nil {
fmt.Println(err)
}
```### Delete
```go
err := mstore.Delete(s, key)
if err != nil {
fmt.Println(err)
}
```### Find
```go
doc, err := mstore.Find(s, key)
if err != nil {
fmt.Println(err)
}
```