Branch: Tag:

2005-11-24

2005-11-24 17:36:50 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added support for having the host in the RAM cache key.
This is needed for proper operation of the hostredirect module.
Thanks to RTL for the suggestion.

Rev: server/base_server/configuration.pike:1.596

5:   // @appears Configuration   //! A site's main configuration    - constant cvs_version = "$Id: configuration.pike,v 1.595 2005/11/24 15:31:06 grubba Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.596 2005/11/24 17:36:50 grubba Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>
216:   // lines of C in HTTPLoop. But it does not have to bother with the   // fact that more than one thread can be active in it at once. Also,   // it does not have to delay free until all current connections using - // the cache entry is done...) + // the cache entry are done...)   class DataCache   {    mapping(string:array(string|mapping(string:mixed))) cache = ([]);
227:       int hits, misses;    +  // FIXME: We ought to have proper varies support here. +  static int host_in_key; +  void need_host_in_key() +  { +  host_in_key = 1; +  } +     void flush()    {   #ifndef RAM_CACHE_NO_RELOAD_FLUSH
256:    }    }    -  void set( string url, string data, mapping meta, int expire ) +  void set(string url, string data, mapping meta, int expire, +  string|void host)    {    if( strlen( data ) > max_file_size ) return;    call_out( expire_entry, expire, url );
267:    clear_some_cache();    }    -  array(string|mapping(string:mixed)) get( string url ) +  array(string|mapping(string:mixed)) get(string url, string|void host)    {    mixed res; -  +  if (host_in_key) { +  url = (host|"") + "\0" + url; +  } else { +  // Forward compat in case host_in_key is enabled later... +  url = "\0" + url; +  }    if( res = cache[ url ] )    hits++;    else