kwiscalesessionmemcached

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2015 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Kwiscale Memcache Session Engine

This package provides a Session Engine to use Memcache.

Installation

Use gopkg.in url to get a versionned package:

go get -u gopkg.in/kwiscale/session-memcached.v0

Then you can import package in you application:

package main

import (
    "gopkg.in/kwiscale/framework"
    _ "gopkg.in/kwiscae/session-memcached"
)

func main(){
    // configuration
    cfg := &kwiscale.Config{
        SessionEngine: "memcached",
        SessionEngineOptions: SessionEngineOptions{
            "prefix": "optional prefix",
            "servers" : []string{
                "192.168.1.5:11211", // at least one server
            }
        }
    }
}

Note that the port is mandatory (at this time).

Documentation

Overview

This package provides memcached support for session on Kwiscale Framework.

To use it, you need to import the package in your application to let runtime call the "init()" function.

import _ "gopkg.in/kwiscale/session-memcached"

Kwiscale will now be able to use session-memcached it you set your App configuration to "memcached":

app := kwiscale.NewApp(&kwiscale.Config{
	SessionEgnine : "memcached",
	SessionEngineOptions: SessionEngineOptions{
		"servers" : "192.168.1.5:11211"
	}
})

The "servers" options could be a coma separated list in string or a slices of strings:

app := kwiscale.NewApp(&kwiscale.Config{
	SessionEgnine : "memcached",
	SessionEngineOptions: SessionEngineOptions{
		"servers" : []string{
			"192.168.1.5:11211",
			"192.168.1.6:11211",
			"192.168.1.7:11211",
			"192.168.1.8:11211",
		}
	}
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemcachedSessionEngine

type MemcachedSessionEngine struct {
	// contains filtered or unexported fields
}

Implement ISessionStore

func (*MemcachedSessionEngine) Clean

func (mc *MemcachedSessionEngine) Clean(handler kwiscale.WebHandler)

Clean removes the entire values in session.

func (*MemcachedSessionEngine) Get

func (mc *MemcachedSessionEngine) Get(handler kwiscale.WebHandler, key interface{}) (interface{}, error)

Get a value from the session.

func (*MemcachedSessionEngine) Init

func (mc *MemcachedSessionEngine) Init()

Register session-memcached in kwiscale.

func (*MemcachedSessionEngine) Name

func (mc *MemcachedSessionEngine) Name(name string)

Name set the name of session (ie. the session cookie name too).

func (*MemcachedSessionEngine) Set

func (mc *MemcachedSessionEngine) Set(handler kwiscale.WebHandler, key, value interface{})

Set value to the session.

func (*MemcachedSessionEngine) SetOptions

func (mc *MemcachedSessionEngine) SetOptions(options kwiscale.SessionEngineOptions)

SetOptions is used here to set servers addresses. Example:

app := kwiscale.NewApp(&kwiscale.Config{
	SessionEngine: "memcached",
	SessionengineOptions: SessionEngineOptions{
		"servers" : "192.168.1.1:11211,192.168.1.2:11211", // required
		"prefix"  : "prefix_string", // optionnal
	}
})

The "servers" list could be a []string or a coma separated list.

func (*MemcachedSessionEngine) SetSecret

func (mc *MemcachedSessionEngine) SetSecret(s []byte)

Set secret []byte to encode session.

Jump to

Keyboard shortcuts

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