memcached

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

package memcached implements a reference store adapter backed by a separate Memcached server.

To be able to use it, add an anonymous import to your main package:

import _ "github.com/digineo/texd/refstore/memcached"

This registers the "memcached://" adapter.

For configuration, use a DSN with the following shape:

dsn := "memcached://host?options"
dir, _ := refstore.NewStore(dsn, nil)

See New() for available options.

Note: This adapter ignores any retention policy. It is expected to configure the Memcached server instance accordingly.

Index

Constants

View Source
const (
	DefaultMaxIdleConns = memcache.DefaultMaxIdleConns
	DefaultTimeout      = memcache.DefaultTimeout
)

Defaults copied from github.com/bradfitz/gomemcache/memcache for clarity

View Source
const (
	// MaxExpiration is the larges value supported for the expiration=<duration>
	// config parameter.
	MaxExpiration = time.Duration(math.MaxInt32) * time.Second

	// DefaultExpiration is used when no expiration=<duration> config parameter
	// is given. This disables automatic expiration.
	DefaultExpiration = 0

	// DefaultKeyPrefix is used with file reference IDs to lookup and store
	// data in Memcached.
	DefaultKeyPrefix = "texd/"
)

Variables

This section is empty.

Functions

func New

New configures a memcached storage adapter. The retention policy is ignored, any data retention and cache invalidation strategy is delegated to the Memcached server.

The following URI parameters are understood (any similarity with github.com/bradfitz/gomemcache/memcache is intentional):

  • addr=<host> adds an additional server to the pool. This option can be specified multiple times. If an address is specified multiple times, it gains a proportional amount of weight. Note: you may omit config.Host, and only use addr=<host> URI parameters.
  • timeout=<duration> to specify the read/write timeout. The parameter value will be parsed with time.ParseDuration(). Values < 0 are invalid (New() will return an error) and the zero value is substituted with a default (100ms).
  • max_idle_conns=<num> specifies the maximum number of idle connections that will be maintained per address. Negative values are invalid, and the zero value is substituted with a default (2).
  • expiration=<duration> adds a lifetime to reference files. A value <= 0 is ignored (no error). The duration must fit into a int32, which imposes a maximum duration of just over 68 years.
  • key_prefix=<string> adds a custom prefix to file reference hashes. By default, this adapter prefixes reference hashes with "texd/".

Note that server addresses (whether provided as DNS host name or via query parameters) should include a port number (by default, Memcached listens on port 11211).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL