piecestore: only check ttl db every hour instead of every 300 nanoseconds (#250)

This commit is contained in:
JT Olio 2018-08-20 15:47:24 -04:00 committed by GitHub
parent 520abc5c73
commit 40f4f7ec31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ package psdb
import (
"context"
"database/sql"
"flag"
"fmt"
"log"
"os"
@ -23,7 +24,9 @@ import (
)
var (
mon = monkit.Package()
mon = monkit.Package()
defaultCheckInterval = flag.Duration("piecestore.ttl.check_interval",
time.Hour, "number of seconds to sleep between ttl checks")
)
// PSDB -- Piecestore database
@ -75,7 +78,10 @@ func OpenPSDB(ctx context.Context, DataPath, DBPath string) (psdb *PSDB, err err
return nil, err
}
return &PSDB{DB: db, dataPath: DataPath, checkInterval: 300}, nil
return &PSDB{
DB: db,
dataPath: DataPath,
checkInterval: *defaultCheckInterval}, nil
}
// deleteEntries -- checks for and deletes expired TTL entries