Coder Social home page Coder Social logo

Auto Shrink dont get triggered about buntdb HOT 7 OPEN

tidwall avatar tidwall commented on May 23, 2024
Auto Shrink dont get triggered

from buntdb.

Comments (7)

h3ku avatar h3ku commented on May 23, 2024

I just make it work with a db.Shrink() at the end, it works fine but I don't have clues of why the AutoShrink don't work.

from buntdb.

tidwall avatar tidwall commented on May 23, 2024

Hi,

I'm sorry to hear that your running into issues. I would like to reproduce this issue on my side.

Do you update your config using the db.WriteConfig function? If so, could you provide your configuration code?

from buntdb.

tidwall avatar tidwall commented on May 23, 2024

Are you still running into this issue? I wasn't able to reproduce it.

from buntdb.

tidwall avatar tidwall commented on May 23, 2024

Iā€™m closing this for now but feel free to reopen if you are still running into problems. Thanks!

from buntdb.

cute-angelia avatar cute-angelia commented on May 23, 2024

func TestAutoShrink2(t *testing.T) {
	dbpath := "/tmp/test_2.db"
	if db, err := buntdb.Open(dbpath); err == nil {
		db.SetConfig(buntdb.Config{
			AutoShrinkDisabled:   true, // not work
			AutoShrinkMinSize:    1,    // not work
			AutoShrinkPercentage: 30,
		})
		for i := 0; i < 20; i++ {
			writeCache2(db)
			time.Sleep(time.Second * 5)
		}
	}
}

func writeCache2(db *buntdb.DB) {
	for i := 0; i < 10000; i++ {
		log.Println("--> ", i)
		val := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
		db.Update(func(tx *buntdb.Tx) error {
			tx.Set(fmt.Sprintf("%s%d", "test", i), val, &buntdb.SetOptions{Expires: true, TTL: time.Hour})
			return nil
		})
	}
}


the db file size is sustained growth ... without Shrink

I would it like file-rotatelogs

from buntdb.

cute-angelia avatar cute-angelia commented on May 23, 2024

@tidwall

from buntdb.

tidwall avatar tidwall commented on May 23, 2024

@cute-angelia

Are you wanting to disable AutoShrink?

Your code is disabling the AutoShrink. This will make the database continue grow until db.Shrink() is called.

from buntdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.