Go Fiber 한글 공식 문서
  • 🙇‍♀️안녕하세요
  • 🏠Home
    • 👋Welcome
    • 📁API
      • 📦Fiber
      • 🚀App
      • 🧠Ctx
      • 📋Constants
      • 🌎Client
      • 📃Log
      • 🧬Middleware
        • Adaptor
        • BasicAuth
        • Cache
        • Compress
        • CORS
        • CSRF
        • EarlyData
        • Encrypt Cookie
        • EnvVar
        • ETag
        • ExpVar
        • Favicon
        • FileSystem
        • Health Check
        • Helmet
        • Idempotency
        • Keyauth
        • Limiter
        • Logger
        • Monitor
        • Pprof
        • Proxy
        • Recover
        • Redirect
        • RequestID
        • Rewrite
        • Session
        • Skip
        • Timeout
    • 📁Guide
      • 🔌Routing
      • 🎭Grouping
      • 📝Templates
      • 🐛Error Handling
      • 🔎Validation
      • 🎣Hooks
      • ⚡Make Fiber Faster
    • 📁Extra
      • 🤔FAQ
      • 📊Benchmarks
  • 🧩Extra
    • 🧬Contrip
      • 👋Welcome
      • Casbin
      • Fgprof
      • Fiberi18n
      • Fibernewrelic
      • Fibersentry
      • Fiberzap
      • Fiberzerolog
      • JWT
      • LoadShed
      • Opafiber
      • Otelfiber
        • Example
      • Paseto
      • README
      • Swagger
      • Websocket
    • 📦Storage
      • 👋Welcome
      • ArangoDB
      • Azure Blob
      • Badger
      • Bbolt
      • Coherence
      • Couchbase
      • DynamoDB
      • Etcd
      • Memcache
      • Memory
      • Minio
      • MongoDB
      • MSSQL
      • MySQL
      • Nats
      • Pebble
      • Postgres
      • Redis
      • Ristretto
      • Rueidis
      • S3
      • ScyllaDb
      • SQLite3
    • 📃Template
      • 👋Welcome
      • Ace
      • Amber
      • Django
      • Handlebars
      • HTML
        • Golang Templates Cheatsheet
      • Jet
      • Mustache
      • Pug
      • Slim
Powered by GitBook
On this page
  • Table of Contents
  • Signatures
  • Installation
  • Examples
  • Config
  • Default Config
  1. Extra
  2. Storage

Memory

PreviousMemcacheNextMinio

Last updated 1 year ago


메모리에 저장하는 스토리지 드라이버입니다.

참고: Go 1.19 이상 버전이 필요합니다

Table of Contents

  • Signatures

  • Installation

  • Examples

  • Config

  • Default Config

Signatures

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)

Installation

go mod init github.com/<user>/<repo>

그런 다음 memory 구현체를 설치하세요:

go get github.com/gofiber/storage/memory/v2

Examples

storage 패키지를 임포트합니다.

import "github.com/gofiber/storage/memory/v2"

다음과 같은 방법으로 storage를 생성할 수 있습니다:

// 기본 설정으로 초기화
store := memory.New()

// 사용자 정의 설정으로 초기화
store := memory.New(memory.Config{
    GCInterval: 10 * time.Second,
})

Config

type Config struct {
    // 만료된 키를 삭제하기 전 시간
    //
    // 기본값은 10 * time.Second
    GCInterval time.Duration
}

Default Config

var ConfigDefault = Config{
    GCInterval: 10 * time.Second,
}

Memory는 모듈을 지원하는 최근 2개 버전에서 테스트되었습니다. 아직 모듈을 초기화하지 않았다면 먼저 초기화해주세요:

🧩
📦
Go versions