Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use local cache for storing tag information #201

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

juev
Copy link
Collaborator

@juev juev commented Aug 20, 2024

Fixed: #199

Since we add a local cache for 20 minutes to store information about golang tags, we can safely access the github api for information about tags. At the same time, we will not receive errors like too many requests.

Currently, the storage time in the cache is strictly specified in the program code and is 20 minutes. It is probably worth considering the ability to change this parameter in the future. If you consider it necessary, you can implement this in the current PR.

Also, adding a file with a local cache allows you to independently prepare this file in a number of environments and put it in the gobrew working directory. This will avoid additional requests to Github for tags. This is for question #197

I tested this solution locally.

@juev juev self-assigned this Aug 20, 2024
@juev juev requested a review from kevincobain2000 as a code owner August 20, 2024 08:11
Copy link

CoverItUp Report

Type master feature/use-cache 338c4a4 from a0caa73
coverage 59.6% 60.5% 📈
build-time 1sec 0sec 📉
go-binary-size 9.0kKB 9.6kKB 📈
go-mod-dependencies 28 28
go-sec-issues 10 12 📈
unit-test-run-time 18sec 19sec 📈
allocs-per-op 19.2kalloc 18.5kalloc 📉
Comparisons Chart - master from feature/use-cache

base vs branchbase vs branchbase vs branchbase vs branchbase vs branchbase vs branchbase vs branch

Commits History

Upto a0caa73 for #201
commit historycommit historycommit historycommit historycommit historycommit historycommit history

Users History

Upto a0caa73 for #201
user historyuser historyuser historyuser historyuser historyuser historyuser history

Embed README.md

@juev juev force-pushed the feature/use-cache branch from a0caa73 to 99ea1a1 Compare August 20, 2024 08:14
Copy link

CoverItUp Report

Comparison Table - 7 Types 📈
Type master feature/use-cache 338c4a4 from 99ea1a1
coverage 59.6% 60.5% 📈
build-time 1sec 0sec 📉
go-binary-size 9.0kKB 9.6kKB 📈
go-mod-dependencies 28 28
go-sec-issues 10 11 📈
unit-test-run-time 18sec 20sec 📈
allocs-per-op 19.2kalloc 18.5kalloc 📉
Comparisons Chart - master from feature/use-cache

base vs branchbase vs branchbase vs branchbase vs branchbase vs branchbase vs branchbase vs branch

Commits History

Upto 99ea1a1 for #201
commit historycommit historycommit historycommit historycommit historycommit historycommit history

Users History

Upto 99ea1a1 for #201
user historyuser historyuser historyuser historyuser historyuser historyuser history

Embed README.md

@kevincobain2000
Copy link
Owner

Ok so you want to get rid of raw GitHub user json and replace it with the GitHub api.
There is however a problem with that when using gobrew on actions or Jenkins on ephemeral modes, since they don’t share the cache.

@kevincobain2000
Copy link
Owner

Just keep the raw GitHub user content. It never gave us any problems.

@juev juev force-pushed the feature/use-cache branch from 99ea1a1 to c31e0c5 Compare August 20, 2024 11:52
@juev
Copy link
Collaborator Author

juev commented Aug 20, 2024

Yes, I had doubts about that. Returned the prepared json back.

Copy link

CoverItUp Report

Comparison Table - 7 Types 📈
Type master feature/use-cache 338c4a4 from c31e0c5
coverage 59.6% 60.5% 📈
build-time 1sec 0sec 📉
go-binary-size 9.0kKB 9.6kKB 📈
go-mod-dependencies 28 28
go-sec-issues 10 11 📈
unit-test-run-time 18sec 20sec 📈
allocs-per-op 19.2kalloc 18.5kalloc 📉
Comparisons Chart - master from feature/use-cache

base vs branchbase vs branchbase vs branchbase vs branchbase vs branchbase vs branchbase vs branch

Commits History

Upto c31e0c5 for #201
commit historycommit historycommit historycommit historycommit historycommit historycommit history

Users History

Upto c31e0c5 for #201
user historyuser historyuser historyuser historyuser historyuser historyuser history

Embed README.md

@kevincobain2000 kevincobain2000 merged commit 77c169c into master Aug 21, 2024
15 checks passed
@kevincobain2000 kevincobain2000 deleted the feature/use-cache branch August 21, 2024 01:51
}

// cache for 20 minutes
if time.Now().UTC().After(timestamp.Add(20 * time.Minute)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought. May be an option as --no-cache on cli to not use cache might do some good?
Or an option --clean-cache to bust the current cache.
It is 20 mins so no problems but might be a good compliance addition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will need to be added. There is also an idea to configure the cache time. Leave 20 minutes by default, but with the ability to set any value.

I created a separate task so I wouldn't forget: #202

@juev juev mentioned this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Information about golang versions
2 participants