func New(config ...Config) Storage
func (s *Storage) Get(key string) ([]byte, error)
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
func (s *Storage) Delete(key string) error
func (s *Storage) Reset() error
func (s *Storage) Close() error
func (s *Storage) Conn() *badger.DB
go mod init github.com/<user>/<repo>
참고: 이 단계는 기존 모듈이 없는 경우에만 필요합니다.
go get github.com/gofiber/storage/pebble/v2
스토리지 패키지를 import합니다.
import "github.com/gofiber/storage/pebble/v2"
// 기본 설정으로 초기화
store := pebble.New()
// 사용자 정의 설정으로 초기화
store := pebble.New(pebble.Config{
Path: "db",
WriteOptions: &pebble.WriteOptions{},
})
type Config struct {
// 데이터베이스 이름
//
// 선택사항. 기본값은 "./db"
Path string
// 쓰기 작업 중 쓰기 옵션 전달
//
// 선택사항. 기본값은 nil
WriteOptions *pebble.WriteOptions
}
var ConfigDefault = Config{
Path: "db",
WriteOptions: &pebble.WriteOptions{},
}