-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.toit
53 lines (40 loc) · 1.04 KB
/
store.toit
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import device
class Store :
store_ := null
key_/string := ""
keyIndex_/string := ""
keyCurrent_/string := ""
constructor .key_ :
keyIndex_ = key_ + "_idx"
keyCurrent_ = key_ + "_current"
init
init :
store_ = device.FlashStore
//print ("store.init was done")
get key/string -> any :
result := store_.get key
//print ("store.get -> $result")
return result
put key/string object/any :
store_.set key object
//print ("$object saved")
return
getIndex -> any :
result := get keyIndex_
//print ("store.getIndex -> $result")
return result
putIndex object/any :
put keyIndex_ object
//print ("store.putIndex $object saved")
return
getCurrent -> any :
result := get keyCurrent_
//print ("store.getIndex -> $result")
return result
putCurrent object/any :
put keyCurrent_ object
//print ("store.putCurrent $object saved")
return
reset current/any index/any :
putCurrent current
putIndex index