Comments (4)
localStorage
offers this functionality as localStorage.clear()
from immortaldb.
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.
@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.
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)
- 😮 WOW! HOT 1
- Add eslint and prettier HOT 4
- how to handle expired mechanism HOT 7
- SSR compatible HOT 6
- Option to remove all cookies set with ImmortalDB HOT 5
- I wouldn't recommend using SessionStorage HOT 3
- Ideas for additional persistent storage HOT 3
- Support for KV Storage HOT 2
- Undefined should not be counted as value? HOT 2
- We don't use NPM or any module manager, so am getting "Cannot use import statement outside a module".... HOT 3
- Events HOT 6
- Add testing how-to snippet to the readme
- Set the SameSite attribute of saved cookies HOT 1
- Indexed DB HOT 1
- Differentiate a user-stored `'undefined'` from a deleted key with a sentinel value
- Use JSDoc HOT 3
- Synchronous get / set? HOT 1
- Size limit HOT 1
- Nextjs window is not defined error HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immortaldb.