def delete(self, key, synchronous=False): ''' Delete the supplied value at the given key. :param key: The key to delete the value at :param synchronous: True to make the put to disk synchronous, False to buffer :throws DatabaseException: If an error has occurred ''' options = LDB.leveldb_writeoptions_create() try: error = new_native_string() LDB.leveldb_writeoptions_set_sync(options, synchronous) LDB.leveldb_delete(self.database, options, key, len(key), get_reference_to(error)) self.handle_error(error) finally: if options: LDB.leveldb_writeoptions_destroy(options)
def write(self, write_batch, synchronous=False): ''' Apply the write batch to the datbase. :param write_batch: The write batch to apply to the database. :param synchronous: True to make the put to disk synchronous, False to buffer :throws DatabaseException: If an error has occurred ''' options = LDB.leveldb_writeoptions_create() try: error = new_native_string() LDB.leveldb_writeoptions_set_sync(options, synchronous) LDB.leveldb_write(self.database, options, write_batch, get_reference_to(error)) self.handle_error(error) finally: if options: LDB.leveldb_writeoptions_destroy(options)