gaesessions

package module
v0.0.0-...-c51a24b Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2016 License: BSD-3-Clause Imports: 13 Imported by: 0

README

gaesessions

session stores for Google App Engine's datastore and memcahe.

Documentation

Index

Constants

View Source
const DefaultNonPersistentSessionDuration = time.Duration(24) * time.Hour

Variables

This section is empty.

Functions

func RemoveExpiredDatastoreSessions

func RemoveExpiredDatastoreSessions(c context.Context, kind string) error

remove expired sessions in the datastore. you can call this function from a cron job.

sample handler config in app.yaml: handlers:

  • url: /tasks/removeExpiredSessions script: _go_app login: admin
  • url: /.* script: _go_app

handler registration code: http.HandleFunc("/tasks/removeExpiredSessions", removeExpiredSessionsHandler)

sample handler:

func removeExpiredSessionsHandler(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	gaesessions.RemoveExpiredDatastoreSessions(c, "")
}

sample cron.yaml: cron:

  • description: expired session removal job url: /tasks/removeExpiredSessions schedule: every 1 minutes

Types

type DatastoreStore

type DatastoreStore struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options // default configuration
	// contains filtered or unexported fields
}

DatastoreStore stores sessions in the App Engine datastore.

func NewDatastoreStore

func NewDatastoreStore(kind string, nonPersistentSessionDuration time.Duration, keyPairs ...[]byte) *DatastoreStore

NewDatastoreStore returns a new DatastoreStore.

The kind argument is the kind name used to store the session data. If empty it will use "Session".

See NewCookieStore() for a description of the other parameters.

func (*DatastoreStore) Get

func (s *DatastoreStore) Get(r *http.Request, name string) (*sessions.Session,
	error)

Get returns a session for the given name after adding it to the registry.

See CookieStore.Get().

func (*DatastoreStore) New

func (s *DatastoreStore) New(r *http.Request, name string) (*sessions.Session,
	error)

New returns a session for the given name without adding it to the registry.

See CookieStore.New().

func (*DatastoreStore) Save

Save adds a single session to the response.

type MemcacheDatastoreStore

type MemcacheDatastoreStore struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options // default configuration
	// contains filtered or unexported fields
}

func NewMemcacheDatastoreStore

func NewMemcacheDatastoreStore(kind, keyPrefix string, nonPersistentSessionDuration time.Duration, keyPairs ...[]byte) *MemcacheDatastoreStore

NewMemcacheDatastoreStore returns a new MemcacheDatastoreStore.

The kind argument is the kind name used to store the session data. If empty it will use "Session".

See NewCookieStore() for a description of the other parameters.

func (*MemcacheDatastoreStore) Get

Get returns a session for the given name after adding it to the registry.

See CookieStore.Get().

func (*MemcacheDatastoreStore) New

New returns a session for the given name without adding it to the registry.

See CookieStore.New().

func (*MemcacheDatastoreStore) Save

Save adds a single session to the response.

type MemcacheStore

type MemcacheStore struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options // default configuration
	// contains filtered or unexported fields
}

MemcacheStore stores sessions in the App Engine memcache.

func NewMemcacheStore

func NewMemcacheStore(keyPrefix string, nonPersistentSessionDuration time.Duration, keyPairs ...[]byte) *MemcacheStore

NewMemcacheStore returns a new MemcacheStore.

The keyPrefix argument is the prefix used for memcache keys. If empty it will use "gorilla.appengine.sessions.".

See NewCookieStore() for a description of the other parameters.

func (*MemcacheStore) Get

func (s *MemcacheStore) Get(r *http.Request, name string) (*sessions.Session,
	error)

Get returns a session for the given name after adding it to the registry.

See CookieStore.Get().

func (*MemcacheStore) New

func (s *MemcacheStore) New(r *http.Request, name string) (*sessions.Session,
	error)

New returns a session for the given name without adding it to the registry.

See CookieStore.New().

func (*MemcacheStore) Save

Save adds a single session to the response.

type Session

type Session struct {
	Date           time.Time
	ExpirationDate time.Time
	Value          []byte
}

Session is used to load and save session data in the datastore.

Jump to

Keyboard shortcuts

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