| 1 | module sessions |
| 2 | |
| 3 | import time |
| 4 | |
| 5 | pub interface Store[T] { |
| 6 | mut: |
| 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. |
| 16 | pub fn (mut s Store[T]) all[T]() ![]T { |
| 17 | return []T{} |
| 18 | } |
| 19 | |
| 20 | // clear all session data, optional to implement. |
| 21 | pub fn (mut s Store[T]) clear[T]() ! {} |
| 22 | |