Documentation
¶
Overview ¶
Package memcache provides a Memcache Client implementation of the driver.Cache interface. It uses the memcache library to interact with a Memcache Client.
URL Format: ¶
The URL should have the following format:
memcache://<host1>:<port1>,<host2>:<port2>,...,<hostN>:<portN>
Each <host>:<port> pair corresponds to the Memcache Client node.
Usage ¶
import (
"context"
"log"
"net/url"
"github.com/bartventer/gocache"
_ "github.com/bartventer/gocache/memcache"
)
func main() {
ctx := context.Background()
urlStr := "memcache://localhost:11211"
c, err := cache.OpenCache(ctx, urlStr)
if err != nil {
log.Fatalf("Failed to initialize cache: %v", err)
}
// ... use c with the cache.Cache interface
}
You can create a Memcache cache with New:
import (
"context"
"log"
"net/url"
"github.com/bartventer/gocache/memcache"
)
func main() {
ctx := context.Background()
c := memcache.New[string](ctx, &memcache.Options{
Addrs: []string{"localhost:11211"},
})
// ... use c with the cache.Cache interface
}
Limitations ¶
Please note that due to the limitations of the Memcache protocol, pattern matching operations are not supported. This includes the cache.Cache Count and DelKeys methods, which will return a cache.ErrPatternMatchingNotSupported error if called.
Index ¶
Constants ¶
View Source
const Scheme = "memcache"
Scheme is the cache scheme for Memcache.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.