22 lines
496 B
V
22 lines
496 B
V
module sessions
|
|
|
|
import time
|
|
|
|
pub interface Store[T] {
|
|
mut:
|
|
// get the current session data if the id exists and if it's not expired
|
|
get(sid string, max_age time.Duration) !T
|
|
// destroy session data for `sid`
|
|
destroy(sid string) !
|
|
// set session data for `val`
|
|
set(sid string, val T) !
|
|
}
|
|
|
|
// get data from all sessions, optional to implement.
|
|
pub fn (mut s Store[T]) all[T]() ![]T {
|
|
return []T{}
|
|
}
|
|
|
|
// clear all session data, optional to implement.
|
|
pub fn (mut s Store[T]) clear[T]() ! {}
|