You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go get github.com/go-sql-driver/mysql
go get github.com/EnumApps/clustersqlstore
go get github.com/EnumApps/aerror
Installation
Run
go get github.com/EnumApps/clustersqlstore
from command line. Gets installed in $GOPATH
Database Config
create table with following SQL
CREATE TABLE session_cluster (
id char(40) NOT NULL COMMENT '2006-01-02T15:04:05.999999999Z07:00+(00000-99999)',
data longblob NOT NULL,
expire_on datetime NOT NULL,
modify_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=ascii;
clean up session with following SQL
CREATE EVENT AutoDeleteOldSession
ON SCHEDULE EVERY 1 HOUR
ON COMPLETION PRESERVE
DISABLE ON SLAVE
DO DELETE LOW_PRIORITY FROM <database>.session_cluster WHERE `expire_on` < DATE_SUB(NOW(), INTERVAL 1 HOUR)
Usage
NewClusterSQLStore takes the following paramaters
driverName - the name of pre-registered cluster drvier, see EnumApps/clustersql (https://github.com/EnumApps/clustersql) for detail
path - path for Set-Cookie header
maxAge - maxAge for session
codecs
Internally, clustersqlstore uses this ClusterSQL driver (not the original one; Since you may using another connection for your major data, this patched version allow multi drivers, each have a custom name).