mirror of
https://github.com/gofiber/storage.git
synced 2025-10-24 00:43:12 +08:00
Update README.md
This commit is contained in:
@@ -1 +1,66 @@
|
||||
# memcache
|
||||
# Memcache
|
||||
|
||||
A Memcache storage driver using [`bradfitz/gomemcache`](https://github.com/bradfitz/gomemcache).
|
||||
|
||||
### Table of Contents
|
||||
- [Signatures](#signatures)
|
||||
- [Examples](#examples)
|
||||
- [Config](#config)
|
||||
- [Default Config](#default-config)
|
||||
|
||||
### Signatures
|
||||
```go
|
||||
func New(config ...Config) fiber.Storage
|
||||
```
|
||||
|
||||
### Examples
|
||||
Import the storage package.
|
||||
```go
|
||||
import "github.com/gofiber/storage/memcache"
|
||||
```
|
||||
|
||||
You can use the following possibilities to create a storage:
|
||||
```go
|
||||
// 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
|
||||
```go
|
||||
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
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
Servers: "localhost:11211",
|
||||
Timeout: 100 * time.Millisecond,
|
||||
MaxIdleConns: 2,
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user