@@ -49,6 +49,7 @@ func main() {
4949 flagSet .StringVarP (& cliOptions .ListenIP , "listen-ip" , "lip" , "0.0.0.0" , "public ip address to listen on" ),
5050 flagSet .IntVarP (& cliOptions .Eviction , "eviction" , "e" , 30 , "number of days to persist interaction data in memory" ),
5151 flagSet .BoolVarP (& cliOptions .NoEviction , "no-eviction" , "ne" , false , "disable periodic data eviction from memory" ),
52+ flagSet .StringVarP (& cliOptions .EvictionStrategy , "eviction-strategy" , "es" , "sliding" , "eviction strategy for interactions (sliding, fixed)" ),
5253 flagSet .BoolVarP (& cliOptions .Auth , "auth" , "a" , false , "enable authentication to server using random generated token" ),
5354 flagSet .StringVarP (& cliOptions .Token , "token" , "t" , "" , "enable authentication to server using given token" ),
5455 flagSet .StringVar (& cliOptions .OriginURL , "acao-url" , "*" , "origin url to send in acao header to use web-client)" ), // cli flag set to deprecate
@@ -230,9 +231,22 @@ func main() {
230231 if cliOptions .NoEviction {
231232 evictionTTL = - 1
232233 }
234+
235+ // Parse eviction strategy
236+ var evictionStrategy storage.EvictionStrategy
237+ switch strings .ToLower (cliOptions .EvictionStrategy ) {
238+ case "fixed" :
239+ evictionStrategy = storage .EvictionStrategyFixed
240+ case "sliding" :
241+ evictionStrategy = storage .EvictionStrategySliding
242+ default :
243+ gologger .Fatal ().Msgf ("invalid eviction strategy '%s', must be 'sliding' or 'fixed'\n " , cliOptions .EvictionStrategy )
244+ }
245+
233246 var store storage.Storage
234247 storeOptions := storage .DefaultOptions
235248 storeOptions .EvictionTTL = evictionTTL
249+ storeOptions .EvictionStrategy = evictionStrategy
236250 if cliOptions .DiskStorage {
237251 if cliOptions .DiskStoragePath == "" {
238252 gologger .Fatal ().Msgf ("disk storage path must be specified\n " )
0 commit comments