symfony
symfony forum
Home » support » General discussion » Database Storage System
Database Storage System [message #10741] Wed, 23 August 2006 01:50 Go to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Hi everyone,
I just posted a Wiki article that offers a system for storing files in a database that uses a caching system. It also addresses the problem of the dot in the query string which seems to pop up on the forum a lot.

If anyone has a chance, could you download the project and make sure that it works for you?

http://www.symfony-project.com/trac/wiki/DatabaseFileStorage System

Thanks.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #10743 is a reply to message #10741 ] Wed, 23 August 2006 03:39 Go to previous messageGo to next message
marckohlbrugge  is currently offline marckohlbrugge
Messages: 164
Registered: January 2006
Senior Member
Nice, will check it out when I have some time.

A quick suggestion:
Add a hash column in your file_info table. This column should contain a hash (e.g; md5 hash) of your file's content so you can easily compare files (e.g. when uploading, so you can disallow duplicates, etc)

Probably out of the scope of this article but could be helpfull for some people.
Re: Database Storage System [message #10750 is a reply to message #10741 ] Wed, 23 August 2006 09:42 Go to previous messageGo to next message
smallbeer  is currently offline smallbeer
Messages: 282
Registered: November 2005
Faithful Member
Thanks for this. A good read Smile
Re: Database Storage System [message #10764 is a reply to message #10741 ] Wed, 23 August 2006 13:56 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
Hi

Thanks, this is great, and just what i needed.

I just wondered if there is any reason for having the file info in a seperate table?

Thanks again

Joe
Re: Database Storage System [message #10863 is a reply to message #10764 ] Thu, 24 August 2006 16:56 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
joesimms wrote on Wed, 23 August 2006 13:56

Hi

I just wondered if there is any reason for having the file info in a seperate table?




Yeah... The reason is for performance issues. We keep the information about the file seperate so we don't need to pull large amounts of Blob data just when we're listing files or when its in the cache. We access the file_data ONLY when we need to.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #10865 is a reply to message #10741 ] Thu, 24 August 2006 17:33 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
Yeah, thats a great idea.

You know what, we could add i18n to these tables as well, so the data can be pulled relevant to culture. This would crack the ability to store and serve translated documents, and interface images?

Image tags could then call an action that returned the image according to the users culture, or if it doesn't exist the default cultures image!

This would result in performance issues as every images would be served from an action and not direct, but if caching considered this it would only a cost on the first request.

Also i am not sure how symfony caches i18n content???? Ummm?
Re: Database Storage System [message #10872 is a reply to message #10865 ] Thu, 24 August 2006 19:35 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Those are good ideas Smile The project I used was just meant to give a starting place for doing that, but feel free to add any other features you want. For i18n I'd just stick a field in file_info to store the culture, and then in the call to retrieveByName in FileInfoPeer just make it check for i18n.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #10896 is a reply to message #10741 ] Fri, 25 August 2006 12:21 Go to previous messageGo to next message
smallbeer  is currently offline smallbeer
Messages: 282
Registered: November 2005
Faithful Member
This method really does seem like having the best of both worlds.

Could this method be used for media files? specifically MP3s? Or would you say the file size involved really shouldn't be stored in the db?
Re: Database Storage System [message #10902 is a reply to message #10896 ] Fri, 25 August 2006 14:44 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
smallbeer wrote on Fri, 25 August 2006 12:21

This method really does seem like having the best of both worlds.

Could this method be used for media files? specifically MP3s? Or would you say the file size involved really shouldn't be stored in the db?


Well, configuration files are one of the limiting factors. The default packet size for mysql defaults to 1 meg, and reading the file info memory causes a hit on what PHP is storing.

I personally haven't tested this method with anything bigger than 4 or 5 meg, but that should be good for MP3s. And yes, this method should work independent of file types. Next week I'll do some tests and see when things start getting sluggish.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13543 is a reply to message #10741 ] Mon, 09 October 2006 23:35 Go to previous messageGo to next message
forkmantis  is currently offline forkmantis
Messages: 37
Registered: November 2005
Location: Texas
Member
Thanks Erestar. This was a great article.

I needed it for a project I'm working on, and found it very easy to implement.

I ran into some trouble with large files, and started looking into different methods of addressing the issue. Google lead me to this page: http://www.dreamwerx.net/phpforum/?id=1

I borrowed the idea of splitting the file into chunks, and made an adaption of your code. I've attached the modified code to this message.

I've implemented a few additional details in my production version that I'd be willing to share if there is interest.

  1. saving file by filename rather than id
  2. cleaning file names to be URL safe
  3. generating subdirectories 3 levels deep to prevent too many files from residing in a single directory
  4. checking for duplicate file name before commit
  5. using checksums to check for duplicate file before commit
  6. allow for a new version of an existing file to be uploaded to the same permalink. Removes old version of the file from cache



will killian
Re: Database Storage System [message #13544 is a reply to message #13543 ] Mon, 09 October 2006 23:55 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
hi forkmantis

those enhancements sound great, i'd really appreciate it if you could please share them.

many thanks

joe
Re: Database Storage System [message #13556 is a reply to message #10741 ] Tue, 10 October 2006 10:08 Go to previous messageGo to next message
smallbeer  is currently offline smallbeer
Messages: 282
Registered: November 2005
Faithful Member
yeah ditto. sounds great and I'll love to hear more of your enhancements Smile
Re: Database Storage System [message #13613 is a reply to message #10741 ] Tue, 10 October 2006 17:15 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
That's awesome forkmantis. I'll take a look at the code this evening.

I'm in the process of implementing this as a new plugin. Its actually just about down, but I'll probably grab your shecksum and splitting method. I'd already done the other things you mentioned.

With your work hopefully I'll finish the plugin system soon and get it uploaded for everyone's review.

Thanks!!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13615 is a reply to message #13613 ] Tue, 10 October 2006 17:21 Go to previous messageGo to next message
forkmantis  is currently offline forkmantis
Messages: 37
Registered: November 2005
Location: Texas
Member
Hmmm... I was just preparing to implement the other features. So do you have them all covered? Is there any point in me doing anything else with the original code at this point? Is there any way I can contribute to the plugin?



will killian
Re: Database Storage System [message #13616 is a reply to message #13615 ] Tue, 10 October 2006 17:24 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Oh, sorry, I misread you!

Tell you what... I'll get the plugin up into the wiki and source and you can take a look. It requires sfGuard to work, and needs some extra interfacey stuff. However, I'd be more than happy to share the workload on getting this up to production quality.

I'm also working on a Photo Gallery plugin that is based on the file storage plugin, so if there's any interest in that I'll post it as well.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13617 is a reply to message #13616 ] Tue, 10 October 2006 17:30 Go to previous messageGo to next message
forkmantis  is currently offline forkmantis
Messages: 37
Registered: November 2005
Location: Texas
Member
Sounds good.

Would it be worth putting up a subversion repository? I'd be willing to host, if need be.



will killian
Re: Database Storage System [message #13618 is a reply to message #13617 ] Tue, 10 October 2006 17:35 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Well, I was gunna try to use symfony's. Otherwise I already have it in my companies repo.

I need to talk to my manager one last time just to make sure that he's still on-board with open-sourcing our CMS application (which is what all of these plugins are for). Shouldn't be a problem though!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13636 is a reply to message #10741 ] Tue, 10 October 2006 22:48 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Still waiting to hear back from Fabien and for my server admin to open up the subversion port.

Until there, here's the plugin.

You'll notice that the bulk of the code from the action has been moved to a utility class, and there's also a utility to unzip compressed files and create database objects for all of them.

Forkmantis,
If you're willing to temporarily setup a repo for this that'd be great. I'm going to continue working on this and my photo gallery tonight, and was hoping you'd have a chance to implement some of your changes into this new plugin architecture.

Thanks!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13668 is a reply to message #13543 ] Wed, 11 October 2006 16:18 Go to previous messageGo to next message
Draven  is currently offline Draven
Messages: 760
Registered: January 2006
Faithful Member
forkmantis wrote on Mon, 09 October 2006 23:35


  1. saving file by filename rather than id
  2. cleaning file names to be URL safe
  3. generating subdirectories 3 levels deep to prevent too many files from residing in a single directory
  4. checking for duplicate file name before commit
  5. using checksums to check for duplicate file before commit
  6. allow for a new version of an existing file to be uploaded to the same permalink. Removes old version of the file from cache



I have a need for this plugin so I'm going to implement most of the above today.

Let me know if you have an SVN going or I'll post the changes back to this post.

A few other options I need to add is.

  • Retrieve a list of files by name and show previews in thumbnail size for use in an article/content system.
  • clean up admin interface a bit and turn this more into a media manager than just a file storage.
  • Files will be stored in same upload cache dir except the first letter of file name will be used to store in alpha-numeric subfolders to organize files.


If you would rather I branch this into a media manager I can do so. Let me know if what I mentioned above doesn't fit your original needs.

[Updated on: Wed, 11 October 2006 16:23]

Re: Database Storage System [message #13669 is a reply to message #13668 ] Wed, 11 October 2006 16:30 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
Hi Draven

I think a media manager plugin is great.

Do you think it would be possible to include a flag in the main table to switch between database storage and file storage, therefore if you want to keep you database lightweight for backup etc, then it will simply store the file in a folder as oppose to the database.

This could then be a universal plugin for file/media management, and let configuration decide which method the dev deems best. it would seem a waste to have to replicate all this code if you didn't want to store the files in the database.

Just an idea.

Thanks

Joe
Re: Database Storage System [message #13670 is a reply to message #10741 ] Wed, 11 October 2006 16:32 Go to previous messageGo to next message
Draven  is currently offline Draven
Messages: 760
Registered: January 2006
Faithful Member
I don't see any problem with that... however, for the moment I'm going to concentrate on the db storage methods, but adding a switch should not be all that difficult once the more complex parts are in.


I'm going to include the sfThumbnail class in this to handle creating different size thumbnails which will be configurable through the module.yml.
Re: Database Storage System [message #13671 is a reply to message #13670 ] Wed, 11 October 2006 16:38 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
i think you can add the sfThumbnail class as a dependency in the pear package file, rather than actually include it, but yeah that is a great idea.
Re: Database Storage System [message #13672 is a reply to message #13670 ] Wed, 11 October 2006 16:39 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Hi guys,
I'd like to keep the file storage plugin kind of seperate from other plugins. The main purpose of this is to make it work with other plugins, like the media storage.

The file plugin should just provide a means for other data objects to transparently access files.

In addition to the file plugin, I also have a gallery plugin in the works.

The gallery plugin offers the ability to associate both a full sized image and a thumbnail with a photo object, which contains tags, description, photographer, etc. I'm in the process of making a very full featured admin section for this to easily allow tag and description changes.

The file plugin allows users to upload zip files, and the gallery provides plugin options.

These plugins are currently at svn://madhatter.pbtg.com/cms/plugins

Checkouts can be anonymous, so if you'd like commit access please just email me at erestar@gmail.com and I'll get you set up.

On some more annoying news, my home internet was out this morning and I had a few more things to commit, but the file plugin (sfPropelFileStoragePlugin) should be stable enough to use.

I look forward on working on these with you. Let me know if you want commit access to the repo.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13676 is a reply to message #10741 ] Wed, 11 October 2006 17:08 Go to previous messageGo to next message
Draven  is currently offline Draven
Messages: 760
Registered: January 2006
Faithful Member
Hi erestar,

I understand and I will branch this off. I understand you want to keep your thumbnails in your photo gallery.

I view this from a different angle as a means for people to admin media for use in any other plugin where using your photo gallery might not be wanted and they still want a means to store and retrieve the photo's in different sizes... to me this should all be in one plugin rather than across several. I don't see why you would want a thumbnail plugin, a file storage plugin, etc etc if you could have it all in one, with methods to retrieve the data in any manner. If you wanted to simply admin the photo's and apply thumbnail resizing you could, but also have the option to store in db. /shrug

I'll branch this off into a different plugin since they will serve very different needs. I will of course give you full credit for the file storage part.

--------------------

Joe, I think I will most likely rewrite a good portion of the sfThumbnail class as I think it's too restrictive in it's present state. Also adding a switch to use either imagemagic or GD.
Re: Database Storage System [message #13677 is a reply to message #13676 ] Wed, 11 October 2006 17:35 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Sounds good Draven. I was initially going in the exact same direction as you, but after thinking about it for a while decided against putting too much into this system.

You're more than free to do whatever you like but the design of this plugin lends its self really well to being used in whatever manner you want. If you want to discuss how your media plugin can simply make use of this plugin I'd be more than happy to talk to you. My only concern is you'll be incorporating this plugin into an existing plugin, which kind of defeats the purpose of plugins, IMHO.

Anyway, let me know how you want to work this!

[Edit]
Oh, and I just wanted to be clear that I'm not trying to be a credit hog here... I'm more concerned about having specific plugins for specific things. The whole point of sfFileStorage is to be used as a plugin in other plugins just like what you're describing. Maybe just take a look at how the sfGalleryPlugin makes use of the sfPropelFileStorage plugin at the SVN link provided previously.

[Updated on: Wed, 11 October 2006 17:37]


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13678 is a reply to message #13677 ] Wed, 11 October 2006 17:38 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Oh, also, I'd be really interested in your new thumbnail plugin, as I've already had to hack the current one several times to get it working how I want. Please keep me posted on its progress.

Thanks!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #13679 is a reply to message #10741 ] Wed, 11 October 2006 17:56 Go to previous messageGo to next message
Draven  is currently offline Draven
Messages: 760
Registered: January 2006
Faithful Member
This doesn't really defeat the purpose of plugins, as a media manager is still a plugin, just a more powerful one.

I don't personally like the idea of having 5 plugins to do the job one plugin could do. To me it's like splitting the sfGuard plugin into sfUser, sfCredentials, sfGroups and sfAuth (think plsitting it's modules into plugins, which is basically the same argument). This seems silly which is why it's just sfGuard. Wink The same idea for a media plugin, rather than having sfFileStorage, sfThumbNail, sfImageFileSystem, etc etc, you just have sfMediaManager with methods to use whichever part is needed in other plugins.

Again, we just have different views on the situation, which is alright. That's the beauty of opensource Wink

I had already planned to build this plugin for a project I have, you just helped jump start one part... thanks again for posting it.

[Updated on: Wed, 11 October 2006 17:59]

Re: Database Storage System [message #13688 is a reply to message #13679 ] Wed, 11 October 2006 18:48 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
I still disagree with your approach but whatever floats your boat! Good luck!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #18012 is a reply to message #10741 ] Sat, 16 December 2006 02:23 Go to previous messageGo to next message
fwave  is currently offline fwave
Messages: 40
Registered: December 2006
Member
nice work to you all, it worked prefect for my project,
continue with the good work
Re: Database Storage System [message #18032 is a reply to message #10741 ] Sun, 17 December 2006 05:08 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Glad to hear it! If you have any feature requests feel free to post them here or ask me or Forkmantis in the IRC channel.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #18546 is a reply to message #18032 ] Thu, 28 December 2006 04:29 Go to previous messageGo to next message
infect  is currently offline infect
Messages: 98
Registered: January 2006
Member
I think there's a small bug in the schema if you're attempting to use this plugin with sfGuard. I'm running symfony 1.0-beta2

The current schema that is used (if you use the "symfony file-storage-set-user-manager sfGuard" task):

    <foreign-key foreignTable="sf_guard_user" phpName="user" >
      <reference local="sf_guard_user_id" foreign="id" />
    </foreign-key>


This should be:
    <foreign-key foreignTable="sf_guard_user">
      <reference local="user_id" foreign="id" />
    </foreign-key>


... since there is no "sf_guard_user_id" column in the file_info table (it's called "user_id").

Also, in the documentation for the plugin, under the section for modifying the .htaccess file, there's a small typo... it should be:

RewriteCond %{REQUEST_FILENAME} !-f


instead of:

Cond %{REQUEST_FILENAME} !-f

[Updated on: Thu, 28 December 2006 04:36]


Mark Quezada
MirthLab
Re: Database Storage System [message #18652 is a reply to message #18546 ] Fri, 29 December 2006 17:06 Go to previous messageGo to next message
forkmantis  is currently offline forkmantis
Messages: 37
Registered: November 2005
Location: Texas
Member
Thanks for pointing this out, infect. I've submitted the fixes you suggested in 3122:

http://www.symfony-project.com/trac/changeset/3122

infect wrote on Wed, 27 December 2006 21:29

I think there's a small bug in the schema...



will killian
Re: Database Storage System [message #21959 is a reply to message #18652 ] Mon, 19 February 2007 11:13 Go to previous messageGo to next message
ksn135  is currently offline ksn135
Messages: 22
Registered: January 2007
Location: Moscow, Russia
Junior Member

For correct handling non-english filenames add 4 lines marked as "++" to serve() function in
\plugins\sfPropelFileStoragePlugin\modules\sfPropelFileStora ge\actions\actions.class.php
<?php
class sfPropelFileStorageActions extends sfActions 
{
...
  protected function 
serve($file_info
  {
...
    
$this->getResponse()->setHttpHeader('content-type'$file_info->getMimeType(), true);
    
$this->getResponse()->setHttpHeader('content-length'$file_info->getSize(), true);
    
++    
$this->getResponse()->setHttpHeader('content-disposition',
++        
sprintf'%s; filename="%s"',
++          (
strstr($_SERVER['HTTP_USER_AGENT'],'MSIE')) ?
++            
'inline' 'attachment'$file_info->getName() ));

    return 
$file_data;        
  }
...
}
?>


And in your template DON'T forget to add urlencode function call:
<?php
...
      
$file $object->getsfPropelFileStorageInfo();
      
$name $file->getName();
      echo 
link_to($name,'@download_by_file_name?name='.urlencode($name));

...
?>


--
WBR,
ksn135.
Re: Database Storage System [message #21960 is a reply to message #21959 ] Mon, 19 February 2007 11:15 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
I'll make those changes tomorrow when I get into the office. Thanks for the tip!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #22080 is a reply to message #21959 ] Tue, 20 February 2007 17:32 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Me and Sporkmantis are working out the best way to make the response headers configurable. Hopefully we'll have something by the end of the day!


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #22225 is a reply to message #21959 ] Wed, 21 February 2007 21:45 Go to previous messageGo to next message
forkmantis  is currently offline forkmantis
Messages: 37
Registered: November 2005
Location: Texas
Member
ksn135 wrote on Mon, 19 February 2007 04:13

For correct handling non-english filenames add 4 lines marked as "++" to serve() function in
\plugins\sfPropelFileStoragePlugin\modules\sfPropelFileStora ge\actions\actions.class.php
...


ksn135,

Could you give us an example of a file you are having trouble w/?



will killian
Re: Database Storage System [message #22261 is a reply to message #22225 ] Thu, 22 February 2007 11:38 Go to previous messageGo to next message
ksn135  is currently offline ksn135
Messages: 22
Registered: January 2007
Location: Moscow, Russia
Junior Member

Ok. For example, let's load two files with long filenames into storage system:
1) text document.txt
2) Текстовый документ.txt
Second one with the same name as first one, BUT only in Russian language. Razz
So, we've got 2 URLs using
<?php
echo link_to($name,'@download_by_file_name?name='.urlencode($name));
?>
:
1) http://localhost/frontend_dev.php/download/text%2Bdocument.t xt
2) http://localhost/frontend_dev.php/download/%25D0%25A2%25D0%2 5B5%25D0%25BA%25D1%2581%25D1%2582%25D0%25BE%25D0%25B2%25D1%2 58B%25D0%25B9%2B%25D0%25B4%25D0%25BE%25D0%25BA%25D1%2583%25D 0%25BC%25D0%25B5%25D0%25BD%25D1%2582.txt
When you click on this links you open text files inside your browser window.
But what's happend when you right click and save link as ?
You've got ugly looking filename in Save As dialog.
Like this one:
1) text+document.txt
2) %D0%A2%D0%B5%D0%BA%D1%81%D1%82%D0%BE%D0%B2%D1%8B%D0%B9+%D0%B 4%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82.txt
If you add 4 lines of my code you get normal human-readable filenames as it appear in database:
1) text document.txt
3) Текстовый документ.txt


--
WBR,
ksn135.
Re: Database Storage System [message #22323 is a reply to message #22261 ] Thu, 22 February 2007 20:40 Go to previous messageGo to next message
infect  is currently offline infect
Messages: 98
Registered: January 2006
Member
Erestar,

Here's an issue I've come across that I wanted to let you know about. After using this plugin for a while (it works pretty well) I noticed that there's really no reason to store the cache status in the database. In this file "modules/sfPropelFileStorage/actions/action.class.php" there's this code:

<?php
if($file_info->getIsCached() && $cache->has($file_info->getId(), 'uploaded_files')) 
{
  
//Ok! We have a cached copy of the file! We're going  to created a throw-away FileData object to
  //store our cached file in.
  
  
$file_data = new sfPropelFileStorageData();
  
$file_data->setBinaryData($cache->get($file_info->getId(), 'uploaded_files'));

}
?>



...the "$file_info->getIsCached()" check can pretty much be omitted as checking if the cache itself has the file is sufficient. In fact, you can remove all instances of this check (as well as removing the field from the database) since checking the actual cache will always be enough to know if you should grab the file from the database. Although this seems to work fine the way it is for smaller things, once this application gets distributed across many servers, the database will get updated with an "isCached = true" status if one of the frontend servers has cached the file, but since the other frontend servers have not cached the file, they'll need to go grab it from the database as well, which basically makes the isCached checking and setting not only useless but it will also execute unnecessary queries on the database (since everytime a file is grabbed from the database, it will update the isCached field).

Let me know if that makes sense or if you'd like more samples.

Thanks again for the great work on this plugin!


Mark Quezada
MirthLab
Re: Database Storage System [message #22325 is a reply to message #22323 ] Thu, 22 February 2007 21:26 Go to previous messageGo to next message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
That's a really good point and I'll chalk that up to an oversite on my part. Fix forthcoming.


Jim Podroskey [www.pbtg.com]
Re: Database Storage System [message #22327 is a reply to message #22325 ] Thu, 22 February 2007 21:56 Go to previous messageGo to previous message
erestar  is currently offline erestar
Messages: 114
Registered: November 2005
Senior Member
Actually, we always need to make a call to the database, because the database should verify that the file exists. Otherwise, in a multiserver environment, the cache file could remain if the file was removed from the DB on another server.

However, discussions with Fork brought up the fairly obvious point that, also in a multiserver env, the first time a file is changed it'll recache on that server, have it's is_cached flag set to true, then continue serving up the old file on other servers.

I'm not positive how I feel about _changing_ the contents of the file to preserve the ID (since it seems to make more sense to just upload a new file and preserve the name) but I'm thinking about implementing timestamps on the cache files and comparing with the created at date.

Anyone have any thoughts?


Jim Podroskey [www.pbtg.com]
Previous Topic:sfPrototypeWindowPlugin problem
Next Topic:sfPrototypeWindowPlugin
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software