https://github.com/uretgec/mydb
Boltdb and Sniper based simple disk with in memory storage unit
https://github.com/uretgec/mydb
bbolt boltdb databases sniper sniperdb storage-api
Last synced: 3 months ago
JSON representation
Boltdb and Sniper based simple disk with in memory storage unit
- Host: GitHub
- URL: https://github.com/uretgec/mydb
- Owner: uretgec
- License: mit
- Created: 2022-05-08T19:22:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-31T00:09:03.000Z (over 3 years ago)
- Last Synced: 2025-10-04T17:44:37.414Z (3 months ago)
- Topics: bbolt, boltdb, databases, sniper, sniperdb, storage-api
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MYDB
It is a storage package containing both in-memory and file-type databases that you can use to hold simple data.
Use:
- bbolt: go.etcd.io/bbolt
- sniper: github.com/recoilme/sniper
NOTE:
> If use only boltdb, all key-value data are at in-memory and saves all data to snapshot file for recovery
> If use only sniperdb, all index data are at in-memory and save all key-value data to file (multiple files)
> sniperdb have to use bboltdb index for list, prevlist, exist methods
> You can use both db together without any problems.
## Examples
Example use go to mydb-server repository -> (https://github.com/uretgec/mydb-server)
## Methods
```
NewStore(bucketList, indexList []string, path string, dbName string, readOnly bool)
CloseStore()
SyncStore()
Set(bucketName []byte, k []byte, data []byte) ([]byte, error)
Get(bucketName []byte, k []byte) ([]byte, error)
MGet(bucketName []byte, keys ...[]byte) (interface{}, error)
List(bucketName []byte, cursor []byte, perpage int) ([]string, error)
PrevList(bucketName []byte, cursor []byte, perpage int) ([]string, error)
Delete(bucketName []byte, k []byte) error
KeyExist(bucketName []byte, k []byte) (bool, error)
ValueExist(bucketName []byte, v []byte) (bool, error)
HasBucket(bucketName []byte) bool
StatsBucket(bucketName []byte) int
ListBucket(bucketName []byte) int
DeleteBucket(bucketName []byte) int
Backup(path, filename string) error
Restore(path, filename string) error
```
## Install
```
go get github.com/uretgec/mydb
```
## TODO
- Add new examples
## Links
Bbolt (https://github.com/etcd-io/bbolt)
Sniper (https://github.com/recoilme/sniper)