Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

google chrome - IndexedDB maximum key value in a key-value storage?

I am writing an application that refreshes indexedDB storage on each reload and generates a new set of key-value pairs on the database. The key value gets incremented each time since I am using objectStore.clear() before writing new key-value pairs.

  1. What is the maximum value I can get to?
  2. Is there a way to reset it to start from 1 again?

I know deleting the object store is one approach for this but the application is a time-sensitive operation and deleting takes some time to complete.

question from:https://stackoverflow.com/questions/65948809/indexeddb-maximum-key-value-in-a-key-value-storage

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The specification for this is at: https://w3c.github.io/IndexedDB/#key-generator-construct. The maximum value is 2^53 (9007199254740992). As the spec notes:

As long as key generators are used in a normal fashion this limit will not be a problem. If you generate a new key 1000 times per second day and night, you won’t run into this limit for over 285000 years.

There is no way to reset the key generator for an object store.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...