func NewStore(adapterName, config string) (TokenStore, error) {
	adapter, ok := adapters[adapterName]
	if !ok {
		return nil, fmt.Errorf("tokenStore: unknown adapter name %q (forgot registration ?)", adapterName)
	}
	if err := adapter.Open(config); err != nil {
		return nil, err
	} else {
		s := &janitorTaget{store: adapter}
		runJanitor(s, time.Minute*5)
		runtime.SetFinalizer(s, stopJanitor)
		return adapter, nil
	}
}
New regiesterd store
package tokenauth
import (
	"fmt"
	"runtime"
	"time"
)
type TokenStore interface {
	Open(config string) error
	Close() error
	SaveAudience(audience *Audience) error
	DeleteAudience(clientID string) error
	GetAudience(clientID string) (*Audience, error)
	SaveToken(token *Token) error
	DeleteToken(tokenString string) error
	GetToken(tokenString string) (*Token, error)
	DeleteExpired()
}
type janitorTaget struct {
	store   TokenStore
	janitor *janitor
}
type janitor struct {
	Interval time.Duration
	stop     chan bool
}
func (j *janitor) Run(taget *janitorTaget) {
	j.stop = make(chan bool)
	tick := time.Tick(j.Interval)
	for {
		select {
		case <-tick:
			taget.store.DeleteExpired()
		case <-j.stop:
			return
		}
	}
}
func stopJanitor(taget *janitorTaget) {
	taget.janitor.stop <- true
}
func runJanitor(taget *janitorTaget, ci time.Duration) {
	j := &janitor{
		Interval: ci,
	}
	taget.janitor = j
	go j.Run(taget)
}
var adapters = make(map[string]TokenStore)
func RegStore(name string, adapter TokenStore) {
	if adapter == nil {
		panic("tokenStore: Register adapter is nil")
	}
	if _, ok := adapters[name]; ok {
		panic("tokenStore: Register called twice for adapter " + name)
	}
	adapters[name] = adapter
}