mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
21 lines
490 B
V
21 lines
490 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) all[T]() ![]T {
|
|
return []T{}
|
|
}
|
|
|
|
// clear all session data, optional to implement.
|
|
pub fn (mut s Store) clear[T]() ! {}
|