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

Proposal: kv db base on remote file system #313

Closed
izouxv opened this issue Jun 7, 2024 · 4 comments
Closed

Proposal: kv db base on remote file system #313

izouxv opened this issue Jun 7, 2024 · 4 comments

Comments

@izouxv
Copy link

izouxv commented Jun 7, 2024

why i want to do this

kv db base on remote file system.
many rosedb instant can r&w the db file without service.
special for mobile app without backend service.

how do i do it

use afero.Fs to replace os.Fs. it can support local or remote fs, and any other type fs
use Lock interface to replace local file lock. i can support local or remote lock
use db interface to replace struct
split the read write api of db api. write with the lock, read without lock

type DBReadOnly interface {
	Close() error
	Fs() afero.Fs
	Stat() *Stat
	Get(key []byte) ([]byte, error)
	Exist(key []byte) (bool, error)
	Ascend(handleFn func(k []byte, v []byte) (bool, error))
	AscendRange(startKey, endKey []byte, handleFn func(k []byte, v []byte) (bool, error))
	AscendGreaterOrEqual(key []byte, handleFn func(k []byte, v []byte) (bool, error))
	AscendKeys(pattern []byte, filterExpired bool, handleFn func(k []byte) (bool, error))
	Descend(handleFn func(k []byte, v []byte) (bool, error))
	DescendRange(startKey, endKey []byte, handleFn func(k []byte, v []byte) (bool, error))
	DescendLessOrEqual(key []byte, handleFn func(k []byte, v []byte) (bool, error))
	DescendKeys(pattern []byte, filterExpired bool, handleFn func(k []byte) (bool, error))
}
type DB interface {
	DBReadOnly
	Sync() error
	Watch() (<-chan *Event, error)
	Put(key []byte, value []byte) error
	PutWithTTL(key []byte, value []byte, ttl time.Duration) error
	Delete(key []byte) error
	Expire(key []byte, ttl time.Duration) error
	TTL(key []byte) (time.Duration, error)
	Persist(key []byte) error
	DeleteExpiredKeys(timeout time.Duration) error

	NewBatch(options BatchOptions) *Batch

	Merge(reopenAfterDone bool) error
}

type Lock interface {
	TryLock() (bool, error)
	Unlock() error
}
@izouxv izouxv changed the title feature: kv db base on remote file system Proposal: kv db base on remote file system Jun 7, 2024
@roseduan
Copy link
Collaborator

Thanks for your proposal.

Are you going to use this new feature in your project?

@izouxv
Copy link
Author

izouxv commented Jun 14, 2024

yes

my project is developing
it is a app that without online server only the remote file system.
this feature can support it

@roseduan
Copy link
Collaborator

yes

my project is developing it is a app that without online server only the remote file system. this feature can support it

Thanks, but I think this is not a common feature for most users.
But you can maintain this yourself.
I don`t have enough motivation to add it to main branch.

@izouxv
Copy link
Author

izouxv commented Jun 15, 2024

ok

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