mirror of
				https://github.com/gofiber/storage.git
				synced 2025-10-31 11:46:32 +08:00 
			
		
		
		
	added garbage collector
This commit is contained in:
		| @@ -3,6 +3,7 @@ package surrealdb | ||||
| import ( | ||||
| 	"log" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // Config holds the configuration required to initialize and connect to a SurrealDB instance. | ||||
| @@ -41,6 +42,9 @@ type Config struct { | ||||
|  | ||||
| 	// The default table used to store key-value records | ||||
| 	DefaultTable string | ||||
|  | ||||
| 	// Optional. Default is 10 * time.Second | ||||
| 	GCInterval time.Duration | ||||
| } | ||||
|  | ||||
| var ConfigDefault = Config{ | ||||
| @@ -52,6 +56,7 @@ var ConfigDefault = Config{ | ||||
| 	Access:           "full", | ||||
| 	Scope:            "all", | ||||
| 	DefaultTable:     "fiber_storage", | ||||
| 	GCInterval:       time.Second * 10, | ||||
| } | ||||
|  | ||||
| func configDefault(config ...Config) Config { | ||||
| @@ -100,5 +105,9 @@ func configDefault(config ...Config) Config { | ||||
| 		log.Printf("Warning: ConnectionString %s doesn't start with ws://, wss://, http:// or https://", cfg.ConnectionString) | ||||
| 	} | ||||
|  | ||||
| 	if int(cfg.GCInterval.Seconds()) <= 0 { | ||||
| 		cfg.GCInterval = ConfigDefault.GCInterval | ||||
| 	} | ||||
|  | ||||
| 	return cfg | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ali Yasir Naç
					Ali Yasir Naç