메모리에 저장하는 스토리지 드라이버입니다.
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() map[string]entry
func (s *Storage) Keys() ([][]byte, error)
go mod init github.com/<user>/<repo>
go get github.com/gofiber/storage/memory/v2
storage 패키지를 임포트합니다.
import "github.com/gofiber/storage/memory/v2"
// 기본 설정으로 초기화
store := memory.New()
// 사용자 정의 설정으로 초기화
store := memory.New(memory.Config{
GCInterval: 10 * time.Second,
})
type Config struct {
// 만료된 키를 삭제하기 전 시간
//
// 기본값은 10 * time.Second
GCInterval time.Duration
}
var ConfigDefault = Config{
GCInterval: 10 * time.Second,
}