/* Orion --- Speech to text bot Copyright (c) 2022 Sameer Rahmani This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package core import "github.com/cockroachdb/pebble" type DB struct { conn *pebble.DB } func CreateDB(path *string) (*DB, error){ conn, err := pebble.Open("demo", &pebble.Options{}) if err != nil { return nil, err } return &DB{ conn, }, nil } func (db *DB) Set(key *string, value *[]byte) error { // Because of our use case we will only use string keys/values return db.conn.Set([]byte(*key), *value, pebble.Sync) } func (db *DB) Get(key *string) (*[]byte, error) { value, closer, err := db.conn.Get([]byte(*key)) if err != nil { return nil, err } defer closer.Close() return &value, nil } func (db *DB) Close(){ db.conn.Close() }