gsession

package
v0.0.0-...-37ff87a Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 16 Imported by: 0

README

GMC Session module

Testing And Code coverage

# go test -cover -v
=== RUN   TestNewSession
--- PASS: TestNewSession (1.00s)
=== RUN   TestSerialize
--- PASS: TestSerialize (0.00s)
=== RUN   TestUnserialize
--- PASS: TestUnserialize (0.00s)
PASS
coverage: 95.6% of statements
ok  	github.com/snail007/gmc/http/session	1.017s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExistsDir

func ExistsDir(path string) bool

func ExistsFile

func ExistsFile(path string) bool

func Init

func Init(config gcore.Config) (sessionStore gcore.SessionStorage, err error)

func NewFileStore

func NewFileStore(config interface{}) (st gcore.SessionStorage, err error)

func NewMemoryStore

func NewMemoryStore(config interface{}) (st gcore.SessionStorage, err error)

func NewRedisStore

func NewRedisStore(config interface{}) (st gcore.SessionStorage, err error)

Types

type FileStore

type FileStore struct {
	gcore.SessionStorage
	// contains filtered or unexported fields
}

func (*FileStore) Delete

func (s *FileStore) Delete(sessionID string) (err error)

func (*FileStore) Load

func (s *FileStore) Load(sessionID string) (sess gcore.Session, isExists bool)

func (*FileStore) Save

func (s *FileStore) Save(sess gcore.Session) (err error)

type FileStoreConfig

type FileStoreConfig struct {
	Dir    string
	GCtime int //seconds
	Prefix string
	Logger gcore.Logger
	TTL    int64 //seconds
}

func NewFileStoreConfig

func NewFileStoreConfig() FileStoreConfig

type MemoryStore

type MemoryStore struct {
	gcore.SessionStorage
	// contains filtered or unexported fields
}

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(sessionID string) (err error)

func (*MemoryStore) Load

func (s *MemoryStore) Load(sessionID string) (sess gcore.Session, isExists bool)

func (*MemoryStore) Save

func (s *MemoryStore) Save(sess gcore.Session) (err error)

type MemoryStoreConfig

type MemoryStoreConfig struct {
	GCtime int //seconds
	Logger gcore.Logger
	TTL    int64 //seconds
}

func NewMemoryStoreConfig

func NewMemoryStoreConfig() MemoryStoreConfig

type RedisStore

type RedisStore struct {
	gcore.SessionStorage
	// contains filtered or unexported fields
}

func (*RedisStore) Delete

func (s *RedisStore) Delete(sessionID string) (err error)

func (*RedisStore) Load

func (s *RedisStore) Load(sessionID string) (sess gcore.Session, isExists bool)

func (*RedisStore) Save

func (s *RedisStore) Save(sess gcore.Session) (err error)

type RedisStoreConfig

type RedisStoreConfig struct {
	TTL      int64 //seconds
	RedisCfg *gcache.RedisCacheConfig
	Logger   gcore.Logger
}

func NewRedisStoreConfig

func NewRedisStoreConfig() RedisStoreConfig

type Session

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

func NewSession

func NewSession() *Session

func (*Session) Delete

func (s *Session) Delete(k interface{}) (err error)

func (*Session) Destroy

func (s *Session) Destroy() (err error)

func (*Session) Get

func (s *Session) Get(k interface{}) (value interface{})

func (*Session) IsDestroy

func (s *Session) IsDestroy() bool

func (*Session) Serialize

func (s *Session) Serialize() (str string, err error)

func (*Session) SessionID

func (s *Session) SessionID() (sessionID string)

func (*Session) Set

func (s *Session) Set(k interface{}, v interface{})

func (*Session) Touch

func (s *Session) Touch()

func (*Session) TouchTime

func (s *Session) TouchTime() (time int64)

TouchTime return the last access unix time seconds of session.

func (*Session) Unserialize

func (s *Session) Unserialize(data string) (err error)

func (*Session) Values

func (s *Session) Values() (data map[interface{}]interface{})

Jump to

Keyboard shortcuts

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