aboutsummaryrefslogtreecommitdiff
path: root/cache.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-22 01:39:41 +0700
committerShulhan <ms@kilabit.info>2026-01-22 01:39:41 +0700
commit79eaccc81b85eb92dab9cf18d52662f367903652 (patch)
treeaf58482138c2ba9211029174ab579e951cd7fff6 /cache.go
parent26fc8bd3203dae6b4705ada227439c90129bbe36 (diff)
downloadjarink-79eaccc81b85eb92dab9cf18d52662f367903652.tar.xz
all: refactoring, use single struct to represent Link
Previously, have [jarink.Link], [brokenlinks.Broken], and [brokenlinks.linkQueue] to store the metadata for a link. These changes unified them into struct [jarink.Link].
Diffstat (limited to 'cache.go')
-rw-r--r--cache.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/cache.go b/cache.go
index 73b4d58..2eeb416 100644
--- a/cache.go
+++ b/cache.go
@@ -80,18 +80,13 @@ func (cache *Cache) Save() (err error) {
return nil
}
-func (cache *Cache) Set(url string, respCode int, size int64) {
+func (cache *Cache) Set(link Link) {
cache.mtx.Lock()
defer cache.mtx.Unlock()
- var scannedLink = cache.ScannedLinks[url]
+ var scannedLink = cache.ScannedLinks[link.Url]
if scannedLink != nil {
return
}
- scannedLink = &Link{
- Url: url,
- Size: size,
- ResponseCode: respCode,
- }
- cache.ScannedLinks[url] = scannedLink
+ cache.ScannedLinks[link.Url] = &link
}