Hi Justin. This one, in my opinion, just like some other posts here, is just another attempt to hammer that square peg into a round hole. Bad idea. I would strongly discourage from going down this path. What are you trying to achieve? If you elaborate more about why you are so concerned about database writes, you may draw some constructive ideas. Is performance of individual db writes so bad, that you are trying to batch-ify them? Is write volume very high?
Boris On Wed, Dec 3, 2008 at 9:41 PM, Justin Mecham <[EMAIL PROTECTED]>wrote: > > Not a problem per se, and yes, I know it's a cache. I was just trying > to avoid having every write hit the database, intending to never > handle a database write until a delete happened, or via an automated > server side process. Like a memcache->dump_to_disk ;-) > > The more I think about it though, an update based on an index probably > isn't a big deal to just run that update... > > My thought though was that I could set it so the database writes only > happened every so often as the user was roaming about the site, but > that leaves me with no recent copy of their data if they from the site > after a few changes, before that frequency write happens. Thus the > thought of a dbase save when that item was deleted. I suppose I could > loop through open users and save people who haven't been saved lately; > that idea appeals to me really. > > Just trying to contribute to the community. :-) Offering the end user > an api spot to access those deleted items seems like a neat idea, if > used cleverly. :-) > > On Dec 3, 9:27 pm, "Josef Finsel" <[EMAIL PROTECTED]> wrote: > > My first thought is... No,let me answer your question a different way by > > asking what problem you are trying to solve. memcached is an in-memory > cache > > which solves the problem of temporary storage of data where it's more > easily > > accessible than the source ( > http://en.wikipedia.org/wiki/Cache_(computing)<http://en.wikipedia.org/wiki/Cache_%28computing%29> > ). > > memcached is not: > > > > - a persistent store > > - a write-through cache > > - a database > > > > Part of why memcached works so well is that it does one thing and one > thing > > only, cache data in memory until either the Expiration time comes or the > > memory is needed as determined by the LRU algorithm. If you want > memcached > > to perform some function, such as call backs for expired/deleted items, > > writing data to the database, high-availability via replicated caches > > between servers, acting as a queue, then you don't want a cache, you want > > something else, and there are a whole host of "extensions" to memcached > like > > memcachedb that probably provide what you need. The reason these are not > in > > memcached is because they add a great deal of overhead that slows down > the > > efficiency of the cache server. > > > > If you have no problem with being tied to a MS platform, you can use > > Velocity, which offers tagging and a whole host of other "improvements" > over > > memcached. But what it doesn't offer is the simple, fast efficiency of > > memcached. I'm currently working with the CTP2 and dreading the fact that > > CTP3 will have a write-through cache because the overhead is ugly. And > > everything Dustin and Dormando say about tags.... I see why they aren't > > implemented in memcached. > > > > So, what problem are you trying to solve? It may be that memcached is a > part > > of it. But having memcached deletes write data to the database is > troubling. > > What happens if someone has directly updated the database between the > time > > the data is stored in the cache and the time it expires. Will the cache > > version overwrite the changes in the database? Will it fail? If it fails, > > should it notify someone? > > > > So tell us what problem you need to solve and we might be able to help > steer > > you to the best solution. > > > > Josef > > > > On Wed, Dec 3, 2008 at 9:08 PM, Justin Mecham <[EMAIL PROTECTED] > >wrote: > > > > > > > > > > > > > I understand how memcached deletes items to be this, proto-code > > > stylie: > > > > > function server_add/replace_value(value){ > > > > > while (server_used_memory>server_max_usable_memory) > > > { > > > delete_oldest_item() > > > } > > > > > server_save(value) > > > > > } > > > > > understanding that the deleted items might more than one, would it be > > > possible to somehow optionally return these deleted values to the > > > functions on the application server? This would be spiffy for > > > controlling database writes. > > > > > a bit more of my shabby proto-code > > > > > $deleted=null; //a variable to return the deleted values into > > > $memcache->add($key,$value,false,600,$deleted); > > > > > if($deleted!=null) > > > { > > > foreach($deleted as $key=>$value) > > > { > > > dbase_save($deleted); > > > } > > > } > > > > > Let me know what you think. :-) > > > > -- > > "If you see a whole thing - it seems that it's always beautiful. Planets, > > lives... But up close a world's all dirt and rocks. And day to day, > life's a > > hard job, you get tired, you lose the pattern." > > Ursula K. Le Guin > > > > http://www.finsel.com/words,-words,-words.aspx(My<http://www.finsel.com/words,-words,-words.aspx%28My>blog) > > - > http://www.finsel.com/photo-gallery.aspx(My<http://www.finsel.com/photo-gallery.aspx%28My>Photogallery) > - > http://www.reluctantdba.com/dbas-and-programmers/blog.aspx(My<http://www.reluctantdba.com/dbas-and-programmers/blog.aspx%28My>Professional > > Blog) > -- --Boris
