fileshredder

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 8 Imported by: 1

README

fileshredder

概述

本库的目标是为了控制文件的生命周期,支持按照存活时间,目录下文件总大小,文件数量来控制。遍历文件顺序是按照文件最后修改时间从小到大。

使用

见 example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	fs.FileInfo
	Path string
}

type FileShredder

type FileShredder struct {
	// contains filtered or unexported fields
}

func NewFileShredder

func NewFileShredder(opts ...Option) (*FileShredder, error)

func (*FileShredder) Close

func (f *FileShredder) Close() error

func (*FileShredder) MillRunOnce

func (f *FileShredder) MillRunOnce(opts ...MillRunOnceOption) error

func (*FileShredder) Run

func (f *FileShredder) Run(ctx context.Context) error

type IsNotDeleteFunc

type IsNotDeleteFunc func(info *FileInfo) bool

type MillRunOnceOption

type MillRunOnceOption func(*MillRunOnceOptions)

func IsNotDelete

func IsNotDelete(fn IsNotDeleteFunc) MillRunOnceOption

type MillRunOnceOptions

type MillRunOnceOptions struct {
	IsNotDelete IsNotDeleteFunc
}

func NewMillRunOnceOptions

func NewMillRunOnceOptions() MillRunOnceOptions

type Option

type Option func(*Options)

func GlobPath

func GlobPath(path string) Option

func Interval

func Interval(d time.Duration) Option

func MaxAge

func MaxAge(age time.Duration) Option

func MaxCount

func MaxCount(count int64) Option

func MaxSize

func MaxSize(size int64) Option

type Options

type Options struct {
	MaxAge   time.Duration
	MaxCount int64
	MaxSize  int64
	GlobPath string
	Interval time.Duration
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL