https://github.com/samuelbankstech/systemicdb-core
This is the core SystemicDB package that is used in the SystemicDB Server, it can be used standalone in a Go project
https://github.com/samuelbankstech/systemicdb-core
database in-memory-database
Last synced: 6 months ago
JSON representation
This is the core SystemicDB package that is used in the SystemicDB Server, it can be used standalone in a Go project
- Host: GitHub
- URL: https://github.com/samuelbankstech/systemicdb-core
- Owner: SamuelBanksTech
- License: other
- Created: 2022-12-13T12:05:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-13T15:51:32.000Z (over 3 years ago)
- Last Synced: 2025-03-05T01:35:27.513Z (over 1 year ago)
- Topics: database, in-memory-database
- Language: Go
- Homepage: https://systemicdb.com
- Size: 236 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](http://golang.org)
[](https://goreportcard.com/report/github.com/SamuelBanksTech/SystemicDB-Core)
[](https://twitter.com/samuelbankstech)
# SystemicDB - Core
### Introduction
This is the core SystemicDB package that is used in the full SystemicDB Server application. I can be imported and used in any Go application for standalone usage or one could wrap their own server around package for custom usage.
### Install
```bash
go get github.com/SamuelBanksTech/SystemicDB-Core
```
### Usage
First of all you will need to instantiate the core SystemicDB struct.
```go
sdb := NewSystemicDB()
```
Insert: Takes a string key, a byte slice as its data, and a expiry time
This function will initiate a database optimisation function (AVL Tree Balancing)
```go
sdb.Insert("my-key", []byte("This is my byte data"), 15 * time.Minute)
```
Exists: Simply returns a bool value to denote whether that key exists or not
```go
sdb.Exists("my-key")
```
Get: Take a key as a string and retrieves a struct containing the nodes data
```go
sdb.Get("my-key")
//Returns...
type NodeData struct {
Key string
Value []byte
Expiry int64 //This is a unix timestamp of the exact time it will expire and bew removed from the database
}
```
Remove: Takes a key as a string, removes the node and all the associated data
This function will initiate a database optimisation function (AVL Tree Balancing)
```go
sdb.Remove("my-key")
```
### TODO
- ❇️ Implement a tag map to allow grouping of keys
- Implement batch operations by tag (Remove By Tag for example)
- ❇️ Produce benchmarks comparison tables (although I already know it's faster than most)
- ❇️ Implement some overrides in struct init that will allow custom timings for Garbage Collection etc