database

package
v1.1.61 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func ClearOldItems

func ClearOldItems()

Clear proxies unusable more than 1 week

func GetAllProxies

func GetAllProxies() (proxies proxy.ProxyList)

Get a proxy list consists of all proxies in database

func InitTables

func InitTables()

func SaveProxiesSpeed added in v1.1.45

func SaveProxiesSpeed(pl proxy.ProxyList)

SaveProxiesSpeed 将测速结果写入数据库(测速完成后调用)。 仅更新 speed 字段,按 identifier upsert。

func SaveProxyList

func SaveProxyList(pl proxy.ProxyList)

SaveProxyList 批量保存可用代理列表。 使用 clause.OnConflict 在唯一索引冲突时更新 useable/name/country, 替代原先逐条 Create+Update 的循环,显著减少 SQL 往返。

Types

type Proxy

type Proxy struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	proxy.Base
	Link       string
	Identifier string `gorm:"unique"`
	// 最近一次测速结果(Mbps),随代理持久化,重启后恢复
	Speed float64
}

设置数据库字段,表名为默认为type名的复数。相比于原作者,不使用软删除特性

Jump to

Keyboard shortcuts

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