Moti Azu
Moti Azu

Reputation: 5442

Default values with SnappyDB

I'm using SnappyDB in my app as a store for some key value pairs. I'm wrapping the DB interface with my own interface with default values in it's api. Example:

String get(String key, String defaultValue);

I noticed the only way to know if a key doesn't exist in the DB is to catch an exception and assume the reason for it was a missing key (which is a wild assumption).

Any ideas on how I could implement the default value feature in a less ugly, more accurate way that won't hide relevant exceptions?

Thanks.

Upvotes: 0

Views: 717

Answers (1)

Nabil Hachicha
Nabil Hachicha

Reputation: 216

You can use:

boolean isKeyExist = snappyDB.exists("key");

Upvotes: 3

Related Questions