v2 / vlib / x / sessions / store.v
21 lines · 17 sloc · 496 bytes · d2e291e5b83a4d00e5f6d1286b39cf92063e6dc5
Raw
1module sessions
2
3import time
4
5pub interface Store[T] {
6mut:
7 // get the current session data if the id exists and if it's not expired
8 get(sid string, max_age time.Duration) !T
9 // destroy session data for `sid`
10 destroy(sid string) !
11 // set session data for `val`
12 set(sid string, val T) !
13}
14
15// get data from all sessions, optional to implement.
16pub fn (mut s Store[T]) all[T]() ![]T {
17 return []T{}
18}
19
20// clear all session data, optional to implement.
21pub fn (mut s Store[T]) clear[T]() ! {}
22