GithubHelp home page GithubHelp logo

Comments (7)

ramnes avatar ramnes commented on August 24, 2024

There isn't, for now! What's your use case?

from mongo-thingy.

Dewsworld avatar Dewsworld commented on August 24, 2024

There isn't, for now! What's your use case?

I want to update the data from the database every 60 secs

from mongo-thingy.

ramnes avatar ramnes commented on August 24, 2024

For a single object or a cursor?

Why not using find or find_one again, every 60 seconds?

from mongo-thingy.

amcgregor avatar amcgregor commented on August 24, 2024

"Refreshing" an object does not involve the construction of a new one, and may potentially be limited to a subset (projection) of fields to be refreshed. Example. (The "TODO" there relates to handling nested/"complex" objects better and the "top level" current limitation.)

Notably, a "refreshed" object will share an identity. (Calling .reload() on one handle reloads the object in-place.)

some_record is some_record.reload()

Whereas the same is not true of multiply-queried documents. Querying again will potentially leave a hanging reference to the old version of the object. (Edit to add: a possible memory leak.)

# With a single record present...
SomeDocument.find_one() is not SomeDocument.find_one()

This seems to be the case, here, as well, unless Thingy is doing some fairly deep magic behind-the-scenes to deduplicate and "cache" multiple instances of the underlying data. Something I strongly dislike other DAO engines doing, as it can lead to problems, which can, ironically, involve a greater need for a reload method.

I want to update the data from the database every 60 secs

@Dewsworld This is referred to as "polling", and is the worst¹ solution to periodic or intermittent data processing. Have you examined Change Streams to pivot to realtime / event-based processing? (I.e. have your application do something when new data comes in, versus asking periodically if there's new data?)

¹ Though sometimes only viable solution. Regardless, it should always remain the solution of last resort.

from mongo-thingy.

ramnes avatar ramnes commented on August 24, 2024

I get the identity argument, but I still don't see a use case for a reload method. On the opposite, I see a lot of value in supporting change streams, yes!

from mongo-thingy.

amcgregor avatar amcgregor commented on August 24, 2024

I apologize for distracting you from a 15 line fix with a potentially multi-hundred-line one. Practicality beats purity, but I will gladly accept a differentiating feature between your solution and mine. Change streams and reloading are distinct, and independently useful. The suggestion was for the developer asking the question initially as an avenue of investigation superior to polling, not that change streams would be a solution to reloading.

from mongo-thingy.

ramnes avatar ramnes commented on August 24, 2024

Alright, let's close this issue for now, we're all loosing our time here.

from mongo-thingy.

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.