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

Can't use db.scan () or db.scanner () in the Go program #40

Closed
gsw945 opened this issue Nov 1, 2024 · 1 comment
Closed

Can't use db.scan () or db.scanner () in the Go program #40

gsw945 opened this issue Nov 1, 2024 · 1 comment

Comments

@gsw945
Copy link

gsw945 commented Nov 1, 2024

The functions signature is as follows:

func (db *DB) Scan(cursor int, pattern string, ktype core.TypeID, count int) (ScanResult, error) {

func (db *DB) Scanner(pattern string, ktype core.TypeID, pageSize int) *Scanner {


The required paremeter ktype must with type core.TypeID, but we can't write code as below:

import "github.com/nalgeon/redka/internal/core"

// example:
// type Logger struct {
// 	DB *redka.DB
// }
// var logger *Logger
// ...
// logger.DB.Key().Scan(0, "*", core.TypeString, 100)

due to error as below:

could not import github.com/nalgeon/redka/internal/core (invalid use of internal package "github.com/nalgeon/redka/internal/core")compiler[BrokenImport](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#BrokenImport)
Package core provides the core types used by other Redka packages.
@nalgeon
Copy link
Owner

nalgeon commented Nov 11, 2024

Fixed in v0.5.3

db, _ := redka.Open("data.db", nil)
defer db.Close()

db.Str().Set("name", "alice")
db.Str().Set("city", "paris")

res, _ := db.Key().Scan(0, "*", redka.TypeString, 100)
fmt.Print("keys:")
for _, key := range res.Keys {
	fmt.Print(" ", key.Key)
}
fmt.Println()

// Output:
// keys: name city

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

No branches or pull requests

2 participants