-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (43 loc) · 1.29 KB
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"log"
// "time"
// "net"
"github.com/Anv3sh/Kioku/internals/constants"
"github.com/Anv3sh/Kioku/internals/services"
"github.com/Anv3sh/Kioku/internals/services/cmdutils"
"github.com/Anv3sh/Kioku/internals/assests"
)
func main() {
assests.PrintLogo()
go cmdutils.CommandRegistry(&constants.REGCMDS, constants.COMMAND_LIST_PATH)
constants.CONFIG.CreateConfig() // to create default config
constants.CONFIG.SetConfig() // to set custom config settings
constants.DICTIONARY.CreateDict(constants.CONFIG)
constants.LFU_CACHE.CreateLFU(constants.CONFIG)
kioku := services.NewKioku()
aoffile,aof:=services.AOFFile(constants.CONFIG.AOFPolicy,constants.CONFIG.AOFPath)
if aof{
services.InMemSync(aoffile, &kioku, &constants.REGCMDS, &constants.DICTIONARY, &constants.LFU_CACHE, &constants.LRU_CACHE, constants.CONFIG)
go services.AOFDiskWrite(aoffile,constants.CONFIG.AOFPolicy,&kioku)
}
go func() {
for {
conn := <-kioku.Connch
msg := <-kioku.Msgch
conn.Write(msg)
}
}()
//ttl logic:
// if constants.CONFIG.Eviction{
// go func(){
// for{
// if len(constants.LFU_CACHE.MinHeap)>0{
// time.Sleep(constants.CONFIG.TotalTimetoLive*time.Second)
// constants.LFU_CACHE.DeleteLF()
// }
// }
// }()
// }
log.Fatal(services.StartListening(&kioku))
}