--- parser3/src/classes/hashfile.C 2001/11/23 12:56:37 1.16 +++ parser3/src/classes/hashfile.C 2001/12/24 09:05:34 1.19 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: hashfile.C,v 1.16 2001/11/23 12:56:37 paf Exp $ + $Id: hashfile.C,v 1.19 2001/12/24 09:05:34 paf Exp $ */ #include "pa_config_includes.h" @@ -38,7 +38,7 @@ static void _open(Request& r, const Stri VHashfile& self=*static_cast(r.self); self.assign( - params->as_string(0, "DB_HOME must be string"), + r.absolute(params->as_string(0, "DB_HOME must be string")), params->as_string(1, "filename must be string") ); } @@ -85,35 +85,27 @@ static void _cache(Request& r, const Str time_t lifespan=(time_t)params->as_double(1, "lifespan must be number", r); Value& body_code=params->as_junction(2, "body must be code"); - // transaction - DB_Transaction transaction(pool, *self.get_table_ptr(&method_name), self.current_transaction); + DB_Table_ptr table_ptr=self.get_table_ptr(&method_name); - // execute body - try { if(lifespan) { // 'lifespan' specified? try cached copy... - if(String *cached_body=transaction.get(key, lifespan)) { // have cached copy? - r.write_assign_lang(*cached_body); - // happy with it - return; - } - } else // 'lifespan'=0, forget cached copy - transaction.remove(key); - - // save - Autosave_marked_to_cancel_cache saved(self); - - // process - Value& processed_body=r.process(body_code); - r.write_assign_lang(processed_body); - - // put it to cache if 'lifespan' specified & never called ^delete[] - if(lifespan && !self.marked_to_cancel_cache()) - transaction.put(key, processed_body.as_string(), lifespan); - } catch(...) { // process/commit problem - transaction.mark_to_rollback(); - - /*re*/throw; - } + if(String *cached_body=table_ptr->get(self.current_transaction, pool, key, lifespan)) { // have cached copy? + r.write_assign_lang(*cached_body); + // happy with it + return; + } + } else // 'lifespan'=0, forget cached copy + table_ptr->remove(self.current_transaction, key); + + // save + Autosave_marked_to_cancel_cache saved(self); + + // process + Value& processed_body=r.process(body_code); + r.write_assign_lang(processed_body); + + // put it to cache if 'lifespan' specified & never called ^delete[] + if(lifespan && !self.marked_to_cancel_cache()) + table_ptr->put(self.current_transaction, key, processed_body.as_string(), lifespan); } static void _delete(Request& r, const String& method_name, MethodParams *params) {