package storage import ( "errors" "log" "os" "strings" "time" ) var ( ErrNotFound = errors.New("password not found") ErrFull = errors.New("storage is filled") ) type entry struct { password []byte expiresAt time.Time } type Store interface { CreatePassword(password []byte, expiresAt time.Time) (string, error) GetPassword(id string) ([]byte, error) Close() error } func NewStore() (Store, error) { storeType := os.Getenv("PASSED_STORE_TYPE") storeType = strings.ToLower(storeType) switch storeType { case "ram": return NewRamStore(20 * time.Second), nil default: log.Printf("No PASSED_STORE_TYPE provided, defaulting to memory store.") return NewRamStore(20 * time.Second), nil } }