git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCHv2 04/10] gitweb: Use Cache::Cache compatibile (get, set) output caching

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 10, 2010, 20:32 UTC
Message-ID
<201002102132.56406.jnareb@gmail.com>
In-Reply-To
<201002101922.50010.jnareb@gmail.com>
Dnia środa 10. lutego 2010 19:22, Jakub Narebski napisał:
Show 7 quoted lines
> Well, the idea was to use PerlIO::Util if possible, checking it via
> 
>   out $use_perlio_layers = eval { require PerlIO::Util; 1 };
> 
> and fallback to generic mechanism if it is not present.  Only the
> generic mechanism would have to be changed from manipulating *STDOUT
> (*STDOUT = $data_fh etc.) to tied filehandle.

Well, damn, this is not needed[1]. Instead of manipulating *STDOUT, it is enough to use 'select FILEHANDLE'. It means that the capture would look like this:

  open my $data_fh, '>', \$data;
  my $oldfh = select($data_fh);
  # ... code that uses 'print <sth>'
  select($oldfh);
  close $data_fh;

One thing that needs to be done is changing 'binmode STDOUT ...' into 'binmode select() ...'

[1] Thanks to mst on #perl channel for pointing this to me.
-- 
Jakub Narebski
Poland
Previous: Jakub NarebskiNext: Jakub Narebski
Message 11 of 18 in “[RFC PATCHv2 00/10] gitweb: Simple file based output caching”
  1. Jakub NarebskiFeb 9, 2010
  2. 01/10 gitweb: href(..., -path_info => 0|1)Jakub Narebski, Feb 9, 2010
  3. 02/10 gitweb/cache.pm - Very simple file based cachingJakub Narebski, Feb 9, 2010
  4. 03/10 gitweb/cache.pm - Stat-based cache expirationJakub Narebski, Feb 9, 2010
  5. 04/10 gitweb: Use Cache::Cache compatibile (get, set) output cachingJakub Narebski, Feb 9, 2010
  6. Jakub NarebskiFeb 10, 2010
  7. Petr BaudisFeb 10, 2010
  8. Jakub NarebskiFeb 10, 2010
  9. Petr BaudisFeb 10, 2010
  10. Jakub NarebskiFeb 10, 2010
  11. Jakub NarebskiFeb 10, 2010
  12. 05/10 gitweb/cache.pm - Adaptive cache expiration timeJakub Narebski, Feb 9, 2010
  13. 06/10 gitweb: Use CHI compatibile (compute method) cachingJakub Narebski, Feb 9, 2010
  14. 07/10 gitweb/cache.pm - Use locking to avoid 'cache miss stampede' problemJakub Narebski, Feb 9, 2010
  15. 08/10 gitweb/cache.pm - Serve stale data when waiting for filling cacheJakub Narebski, Feb 9, 2010
  16. 09/10 gitweb/cache.pm - Regenerate (refresh) cache in backgroundJakub Narebski, Feb 9, 2010
  17. Jakub NarebskiFeb 9, 2010
  18. 10/10 gitweb: Show appropriate "Generating..." page when regenerating cacheJakub Narebski, Feb 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.