Arduino Extended Database Library in RAM: is it possible?

Hello all. I'm trying to use a data structure like Extended Database Library but I need it to work in RAM instead of EEPROM or any other permanent media. The platform is the ESP8266 (using Arduino IDE) which has a fair amount of RAM to work with. Looking at the library code, I see that read and write handlers can be modified according to the desired storage type, for example:

void writer(unsigned long address, byte data)
{
  EEPROM.write(address, data);
}

Will write one byte to desired EEPROM location. I'm trying to figure out how to manage this library to work in RAM. Do I need to initialize an unsigned char array of the maximum size (let's say, for example, 8K bytes) of the database? Any hints? Thanks in advance.

Gabriele

I'm curious what purpose a non-persistent database serves. If you lose power, the database starts over empty. How is that useful?

ESP8266 uses flash to emulate EEPROM for compatibility with Arduino. See the EEPROM section of http://arduino.esp8266.com/versions/1.6.5-990-gc8a63ce/doc/reference.html for more information.

What happens is when you call EEPROM.begin() it copies the flash contents to RAM and then all EEPROM.read/write/put/get() calls operate on the RAM copy. The data is only written to flash when you call EEPROM.commit() or EEPROM.end(). So it's possible that using the library with "EEPROM" on the ESP8266 may already be doing what you want it to do.

Thank you pert for your useful suggestion. Indeed, avoiding to commit final EEPROM write from RAM is equivalent to have it working [u]only[/u] in RAM. I'll try to use it this way. To PaulS: what I'm trying to implement is a communication system between different ESP8266s (each one storing some data) and I need a local data cache on each ESP8266. It doesn't matter if after a power outage the data won't be available anymore: it'll be fetched again from the other ESP8266 nodes. What I need is a local cache (optimized to avoid, at least, heap fragmentation) to query (but also insert, delete and update) without the need to ask from a master node at each data requested by local ESP8266. Powering down the ESP8266 will clear that memory and it'll be filled in again after some queries from the network. I'm also accepting better ideas if you have ;) Thank you again.