Files
storage/memcache
2020-11-02 14:20:15 +01:00
..
2020-11-02 14:14:01 +01:00
2020-11-02 13:45:21 +01:00
2020-11-02 14:20:15 +01:00

Memcache

A Memcache storage driver using bradfitz/gomemcache.

Table of Contents

Signatures

func New(config ...Config) fiber.Storage

Examples

Import the storage package.

import "github.com/gofiber/storage/memcache"

You can use the following possibilities to create a storage:

// Initialize default config
store := memcache.New()

// Or extend your config for customization
store := memcache.New(csrf.Config{
	Servers:        "localhost:11211, localhost:5678",
	Timeout:        100 * time.Millisecond,
	MaxIdleConns:   10,
})

Config

type Config struct {
	// Server list divided by ,
	// i.e. server1:11211, server2:11212
	//
	// Optional. Default is "localhost:11211"
	Servers string

	// The socket read/write timeout.
	//
	// Optional. Default is 100 * time.Millisecond
	Timeout time.Duration

	// The maximum number of idle connections that will be maintained per address.
	//
	// Consider your expected traffic rates and latency carefully. This should
	// be set to a number higher than your peak parallel requests.
	//
	// Optional. Default is 2
	MaxIdleConns int
}

Default Config

var ConfigDefault = Config{
	Servers:      "localhost:11211",
	Timeout:      100 * time.Millisecond,
	MaxIdleConns: 2,
}