views:

83

answers:

2

I'm working with Datamapper which allows you to specify either a path to a database file on your system or simply the string "memory" and then an "in-memory" database is used. However, I have no idea what this means.

Is an "in-memory" database purely memory-based or does it get serialized to the filesystem at some point?

What's the benefit of an in-memory database?

Is it simply for efficiency - by removing the cost of filesystem access?

+1  A: 

The reason why SQLite has in-memory databases isn't really for performance. In practice, having a file isn't really any slower than skipping that, except if you run out of memory. It's really mostly for temporary caching or testing. For instance you could use an in-memory db for your unit tests, so that you don't walk on production data. Or you could use it as an alternative to memcache if you wanted SQL functionality. Basically, it's there so you don't have to persist data, if you don't need to.

TokenMacGuy
+1  A: 

From the SQLite documentation:

If the filename is ":memory:", then a private, temporary in-memory database is created for the connection. This in-memory database will vanish when the database connection is closed.

By the way, did you ever find the file you were looking for?

Adam Bernier
Yes, thanks, I found it by accident in my root directory. It didn't show up in any of my searches for some reason. Somehow Datamapper ignored the path I had given it in my setup instructions and simply dumped it in the root directory. I think the path I gave it was from the filesystem root instead of the project root and it wasn't able to find the /db/ folder off the root folder so it just dropped it in root. Thanks for the tips though.
F. Matthews