Git Product home page Git Product logo

Comments (4)

puckey avatar puckey commented on May 18, 2024

localStorage offers this functionality as localStorage.clear()

from immortaldb.

gruns avatar gruns commented on May 18, 2024

This is tricky.

ImmortalDB strives to remain agnostic of the underlying key:value storage
implementation(s). As such, it's not currently a requirement that underlying
key:value stores provide method(s) to iterate through keys, a requirement to
implement a clear() method.

For example, imagine you added a custom RemoteNetworkStore to ImmortalDB
that connects to a remote key:value store over a WebSocket. That remote
key:value store might have millions of keys, a la Firestore, and not have an
efficient mechanism to iterate through all keys.

We need to thoughtfully consider whether key iteration should be a requirement
for storage implementations.

What are your thoughts here?

I'll ruminate on this.

from immortaldb.

anthonylebrun avatar anthonylebrun commented on May 18, 2024

@gruns First off, I just discovered this library. It's quite clever, thanks for writing it!

As such, it's not currently a requirement that underlying key:value stores provide method(s) to iterate through keys

What if you make a requirement for all stores to provide a clear() method, but also have the convention that it can return false meaning that it does not implement that functionality. ImmortalDB could log a warning or something - since the main use case for this would be testing / development and not production.

Win/Win I think :)

from immortaldb.

gruns avatar gruns commented on May 18, 2024

What if you make a requirement for all stores to provide a clear() method, but
also have the convention that it can return false meaning that it does not
implement that functionality.

Quite reasonable. I rather like it.

Throwing a NotImplementedError (or similar) exception is better expected
behavior than returning false, though.

In scenarios where the majority of stores don't implement clear(), one could
call clear() and then get() and the get() would succeed. Which would be
confusing. This is, of course, an unrealistic scenario, but nonetheless entirely
possible.

Another interesting note: to implement clear(), iteration is required. And
when iteration is provided, keys(), values(), and entries() are also
trivially added.

from immortaldb.

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.