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

[improvement] Small cache size #1775

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service/intel/filterlists/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
var cache = database.NewInterface(&database.Options{
Local: true,
Internal: true,
CacheSize: 2 ^ 8,
CacheSize: 256,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix critical bug: Correct cache size from XOR to power operation

The change from 2 ^ 8 to 256 fixes a critical bug where the XOR operator (^) was mistakenly used instead of power operation, resulting in a cache size of 10 instead of 256 (2⁸).

Consider adding a constant to make the intention clear:

+const (
+    // defaultCacheSize is 2⁸, providing reasonable caching for filter list entries
+    defaultCacheSize = 256
+)

var cache = database.NewInterface(&database.Options{
    Local:     true,
    Internal:  true,
-    CacheSize: 256,
+    CacheSize: defaultCacheSize,
})

Committable suggestion skipped: line range outside the PR's diff.

})

// getFileFunc is the function used to get a file from
Expand Down
Loading