/
storage.go
35 lines (27 loc) · 1.01 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package app
var (
// LocalStorage is a storage that uses the browser local storage associated
// to the document origin. Data stored has no expiration time.
LocalStorage BrowserStorage
// SessionStorage is a storage that uses the browser session storage
// associated to the document origin. Data stored expire when the page
// session ends.
SessionStorage BrowserStorage
)
// BrowserStorage is the interface that describes a web browser storage.
type BrowserStorage interface {
// Set sets the value to the given key. The value must be json convertible.
Set(k string, v interface{}) error
// Get gets the item associated to the given key and store it in the given
// value.
// It returns an error if v is not a pointer.
Get(k string, v interface{}) error
// Del deletes the item associated with the given key.
Del(k string)
// Len returns the number of items stored.
Len() int
// Key returns the key of the item associated to the given index.
Key(i int) (string, error)
// Clear deletes all items.
Clear()
}