Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.1092 2011/11/23 10:12:46 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1093 2011/11/29 17:33:49 anders Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:4028:    }    meta_cache = ([]);    }       void flush(int|void age)    //! Flush the cache. If an age (an integer as returned by    //! @[time()]) is provided, only images with their latest access before    //! that time are flushed.    {    int num; - #ifdef DEBUG + #if defined(DEBUG) || defined(IMG_CACHE_DEBUG)    int t = gethrtime();    report_debug("Cleaning "+name+" image cache ... ");   #endif    sync_meta();    uid_cache = ([]);    rst_cache = ([]);    if( !age )    { - #ifdef DEBUG + #if defined(DEBUG) || defined(IMG_CACHE_DEBUG)    report_debug("cleared\n");   #endif    QUERY( "DELETE FROM "+name );    num = -1;    return;    }       array(string) ids =    QUERY( "SELECT id FROM "+name+" WHERE atime < "+age)->id;       num = sizeof( ids );       int q;    while(q<sizeof(ids)) {    string list = map(ids[q..q+99], get_db()->quote) * "','";    q+=100; -  QUERY( "DELETE FROM "+name+" WHERE id in ('"+list+"')" ); +  QUERY( "DELETE LOW_PRIORITY FROM "+name+" WHERE id in ('"+list+"')" );    }      #if 0    // Disabled. This can take a significant amount of time to run,    // and we really can't afford an unresponsive image cache - it can    // easily hang all handler threads. Besides, it's doubtful if this    // is of any use since the space for the deleted records probably    // will get reused soon enough anyway. /mast    if( num )    catch    {    // Old versions of Mysql lacks OPTIMIZE. Not that we support    // them, really, but it might be nice not to throw an error, at    // least. - #ifdef DEBUG + #if defined(DEBUG) || defined(IMG_CACHE_DEBUG)    report_debug("Optimizing database ... ", name);   #endif    QUERY( "OPTIMIZE TABLE "+name );    };   #endif    - #ifdef DEBUG + #if defined(DEBUG) || defined(IMG_CACHE_DEBUG)    report_debug("%s removed (%dms)\n",    (num==-1?"all":num?(string)num:"none"),    (gethrtime()-t)/1000);   #endif    }       array(int) status(int|void age)    //! Return the total number of images in the cache, their cumulative    //! sizes in bytes and, if an age time_t was supplied, the number of    //! images that has not been accessed after that time is returned
Roxen.git/server/base_server/roxen.pike:4395:    master()->resolv("DBManager.is_module_table")    ( 0,"local",name,"Image cache for "+name);       QUERY("CREATE TABLE "+name+" ("    "id CHAR(64) NOT NULL PRIMARY KEY, "    "size INT UNSIGNED NOT NULL DEFAULT 0, "    "uid CHAR(32) NOT NULL DEFAULT '', "    "atime INT UNSIGNED NOT NULL DEFAULT 0,"    "meta MEDIUMBLOB NOT NULL DEFAULT '',"    "data MEDIUMBLOB NOT NULL DEFAULT ''," -  "INDEX atime (atime)" +  "INDEX atime_id (atime, id)"    ")" );    } -  +  +  // Create index in old databases. Index is used when flushing old +  // entries. Column 'id' is included in index in order to avoid +  // reading data file. +  array(mapping(string:mixed)) res = QUERY("SHOW INDEX FROM " + name); +  if(search(res->Key_name, "atime_id") < 0) { +  report_debug("Updating " + name + " image cache: " +  "Adding index atime_id on %s... ", name); +  int start_time = gethrtime(); +  QUERY("CREATE INDEX atime_id ON " + name + " (atime, id)"); +  report_debug("complete. [%f s]\n", (gethrtime() - start_time)/1000000.0); +  report_debug("Updating " + name + " image cache: " +  "Dropping index atime on %s... ", name); +  start_time = gethrtime(); +  QUERY("DROP INDEX atime ON " + name); +  report_debug("complete. [%f s]\n", (gethrtime() - start_time)/1000000.0);    } -  +  }       Sql.Sql get_db()    {    return dbm_cached_get("local");    }       protected void init_db( )    {    catch(sync_meta());    setup_tables();