...

Source file src/github.com/gin-contrib/sessions/memcached/memcached.go

Documentation: github.com/gin-contrib/sessions/memcached

     1  package memcached
     2  
     3  import (
     4  	"github.com/bradfitz/gomemcache/memcache"
     5  	gsm "github.com/bradleypeabody/gorilla-sessions-memcache"
     6  	"github.com/gin-contrib/sessions"
     7  )
     8  
     9  type Store interface {
    10  	sessions.Store
    11  }
    12  
    13  // client: memcache client (github.com/bradfitz/gomemcache/memcache)
    14  // keyPrefix: prefix for the keys we store.
    15  func NewStore(
    16  	client *memcache.Client, keyPrefix string, keyPairs ...[]byte,
    17  ) Store {
    18  	memcacherClient := gsm.NewGoMemcacher(client)
    19  	return NewMemcacheStore(memcacherClient, keyPrefix, keyPairs...)
    20  }
    21  
    22  // client: memcache client which implements the gsm.Memcacher interface
    23  // keyPrefix: prefix for the keys we store.
    24  func NewMemcacheStore(
    25  	client gsm.Memcacher, keyPrefix string, keyPairs ...[]byte,
    26  ) Store {
    27  	return &store{gsm.NewMemcacherStore(client, keyPrefix, keyPairs...)}
    28  }
    29  
    30  type store struct {
    31  	*gsm.MemcacheStore
    32  }
    33  
    34  func (c *store) Options(options sessions.Options) {
    35  	c.MemcacheStore.Options = options.ToGorillaOptions()
    36  }
    37  

View as plain text