Skip to main content
Inspiring
Sep 8, 2010 4:26 PM UTC
Answered

To cache binaries as a BLOB or on file system?

I originally posted this AIR question on the Flex forum, which didn't get much attention, so now I am trying here which seems more ideal.

My question in detail:

     Would it be more optimal to store binaries (Images and SWFs) as BLOBs in the database or to have a URI pointing to them on the user’s file system?

I am primarily a Flex developer which hasn't had much development time with databases but realizes there are 2 options to take for storing binaries in an AIR application.  Since I haven't been exposed to db development I am not sure which is the preferred way.

This topic is closed to new replies. Start a new post to keep the conversation going.
ilssac
ilssacCorrect answer
Inspiring
Sep 9, 2010 1:22 PM UTC

You are right there are two options, and they are both commonly used.

Storing on the file system is a bit easier to implement for many and might be a touch more proformant with less encoding and decoding going on.  But it has a higher risk of syncornazation  problems since there are many ways for the file objects to be modified, moved or removed without changing anything and the database.  Thus one should build logic that will check for the actual existence of the file at the URI before trying to serve it up.

Storing the file in the database mitigates the issues with syncornazation.  But it takes a bit more to set up and could involve a lot more data in the database itself, which may or may not be an issue depending on ones setup.

But either is an acceptiable choice and just work with the various pros and cons of either.

2 replies

ilssac
ilssacCorrect answer
Inspiring
Sep 9, 2010 1:22 PM UTC

You are right there are two options, and they are both commonly used.

Storing on the file system is a bit easier to implement for many and might be a touch more proformant with less encoding and decoding going on.  But it has a higher risk of syncornazation  problems since there are many ways for the file objects to be modified, moved or removed without changing anything and the database.  Thus one should build logic that will check for the actual existence of the file at the URI before trying to serve it up.

Storing the file in the database mitigates the issues with syncornazation.  But it takes a bit more to set up and could involve a lot more data in the database itself, which may or may not be an issue depending on ones setup.

But either is an acceptiable choice and just work with the various pros and cons of either.

Translate
injpixAuthor
Inspiring
Sep 10, 2010 2:10 PM UTC

ilssac, thanks for the feedback!

I think I am going to try to save the binaries directly in the database.  Saving a binary on the file system would involve 2 easy steps:  storing the URI in the db and saving the binary on the file system.  But as you mentioned there are risks involved.

I started this task yesterday and I am saving BLOBs to the db, but will now just need to decode them when requested.  If the performance is good when decoding them, I believe I will stay with this option.  If not, I will resort to storing them on the file system.

Thanks again.

Translate