Comments (11)
@vweevers Extremely sorry for my word, you are so helpful, Thank You for Helping me.
from level.
Multiple solutions exist for this. Depends on several factors: how do you want your keys to be sorted, should they be globally unique, are your writes random or sequential, do you delete keys and if so do you want to allow reuse, etc. This is all up to you.
Can you be more specific?
from level.
@vweevers I want globally unique & sequential, it may delete and reuse.
Can you please send an example?
from level.
Using ulid
as keys may work for you. E.g.:
const ulid = require('ulid').monotonicFactory()
await db.put(ulid(), 'example')
from level.
ulid() will this package never genarate same id, every time will it genarate unique id?
Can i use uniqid/nanoid/uuid package for Maintaining Global Uniqueness?
from level.
ulid() will this package never genarate same id, every time will it genarate unique id?
It has 80 bits of randomness (see spec). Should be sufficiently unique, but that's your call.
Can i use uniqid/nanoid/uuid package for Maintaining Global Uniqueness?
The benefit of ulid
is that the generated ids sort lexicographically and increase monotonically. If you stream or iterate keys from your db, you get them back in insertion order.
from level.
-
Yes, I understood but this repository not upgrade till 2019, Can you please a recently upgraded repository?
-
leveldb performance is High in sequential key or in random key, which one make leveldb performance better?
from level.
Sequential, for sure.
from level.
@vweevers Please answer my questions
- Yes, I understood but this repository not upgrade till 2019, Can you please a recently upgraded repository?
- leveldb performance is High in sequential key or in random key, which one make leveldb performance better?
from level.
Your tone is too demanding - also in ulid/javascript#88 - and I frankly don't feel like explaining why that is an issue. So I'm just gonna leave this thread until you realize it yourself. Good luck!
from level.
Thank you! To answer your first question:
Yes, I understood but this repository not upgrade till 2019, Can you please a recently upgraded repository?
ulid
is stable as far as I know, and dependency-free, so naturally it's light on maintenance. I don't know of other UUID generators that sort in the same way, but I'm sure they can be found.
For inspiration, you might want to look at flakeid
(written in Go but conceptually relevant), monotonic-lexicographic-timestamp
(only unique per-machine, not globally) and modules listed in awesome.
Lastly, you can of course write your own solution, which has the benefit that you can optimize it for your specific use case. For example, let's say you have a cluster of machines and you already have a known distinct name for each machine, then you could construct keys in the form of <timestamp>~<name>
or <sequence number>~<name>
.
from level.
Related Issues (20)
- Question: Fetch all values HOT 5
- Insert Lock, Read Lock, Dead Lock Concatency Control HOT 2
- Find specific key createReadStream HOT 6
- docker node alpine image exited with code 139 (arm32v7) HOT 4
- Can this be used to polyfill IndexedDB on Node? HOT 3
- [Question] how can "level-js" make data persistence? HOT 2
- db.isOperational is not a function HOT 2
- Trying to store different types of data but getting stored as string HOT 1
- Error while creating a web bundle with esbuild HOT 1
- Recommended way of retrieving a list of all keys? HOT 1
- Exception handling during storing a value HOT 4
- Live streaming values from a level HOT 6
- Types do not export `destroy` property HOT 1
- Random "Error: Database is not open" errors HOT 14
- Minor Compactions is triggered frequently
- Every time my node script restarts, it creates a new .LDB file in the database directory HOT 1
- Checking if a key exists HOT 1
- Get read access to locked database HOT 1
- how to get all sublevel db HOT 2
- No native build was found error on MacOS with M1 processor HOT 3
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 level.