How to limit LevelDB maximum disk size ?

739 views
Skip to first unread message

Adong Fan

unread,
Dec 26, 2017, 4:15:02 AM12/26/17
to leveldb

hi all

I want to use leveldb as a local-storage-mechanism: when i send to messages to message-queue-server fail , i will store the messages locally.

my question is :

1. how to limit the maximum disk space for levelDB?otherwise it may grow bigger and bigger ?

2. If there is no max-disk-space limit  in LevelDB ? what can i do to limit the total size in my web app ? e.g.  Caculate the total num of .sst file ?


Victor Costan

unread,
Dec 28, 2017, 7:02:22 PM12/28/17
to lev...@googlegroups.com
On Tue, Dec 26, 2017 at 1:15 AM Adong Fan <fanad...@gmail.com> wrote:

hi all

I want to use leveldb as a local-storage-mechanism: when i send to messages to message-queue-server fail , i will store the messages locally.

my question is :

1. how to limit the maximum disk space for levelDB?otherwise it may grow bigger and bigger ?

LevelDB does not have any support for quota right now. In Chrome, we handle this by accounting for quota in the features built on top of LevelDB.


2. If there is no max-disk-space limit  in LevelDB ? what can i do to limit the total size in my web app ? e.g.  Caculate the total num of .sst file ?

"In my web app" is a bit vague. If you're writing JavaScript that runs in the browser, you can use the quota API to find out your origin's data usage.

Sadly, there are 3 versions of the quota API floating around. Fortunately, the modern API can be polyfilled on top of the older ones. The modern API is https://developer.mozilla.org/en-US/docs/Web/API/StorageManager

I hope this helps,
    Victor

Reply all
Reply to author
Forward
0 new messages