NAME

Weather::Com::Cached - Perl extension for getting weather information from weather.com

SYNOPSIS

  use Data::Dumper;
  use Weather::Com::Cached;
  
  # define parameters for weather search
  my %params = (
		'cache'      => '/tmp/weathercache',
		'current'    => 1,
		'forecast'   => 3,
		'links'      => 1,
		'units'      => 's',
		'proxy'      => 'http://proxy.sonstwo.de',
		'timeout'    => 250,
		'debug'      => 1,
		'partner_id' => 'somepartnerid',
		'license'    => '12345678',
  );
  
  # instantiate a new weather.com object
  my $cached_weather = Weather::Com::Cached->new(%params);
  
  # search for locations called 'Heidelberg'
  my $locations = $cached_weather->search('Heidelberg')
  	or die "No location found!\n";
  
  # and then get the weather for each location found
  foreach (keys %{$locations}) {
	my $weather = $cached_weather->get_weather($_);
	print Dumper($weather);
  }

DESCRIPTION

Weather::Com::Cached is a Perl module that provides low level OO interface to gather all weather information that is provided by weather.com.

Please refer to Weather::Com for the high level interfaces.

This module implements the caching business rules that apply to all applications programmed against the xoap API of weather.com. Except from the cache parameter to be used while instantiating a new object instance, this module has the same API than Weather::Com::Base. It's only a simple caching wrapper around it.

The caching mechanism for location searches is very simple. We assume that location codes on weather.com will never change. Therefore, a search string that has been successfully used once to search for locations will never cause another search on the web. Each location search results will be stored in the file locations.dat. If you want to refresh your locations cache, simply delete this file.

Although it's really simple, the module uses Storable methods lock_store and lock_retrieve to implement shared locking for reading cache files and exclusive locking for writing to chache files. By this way the same cache files should be able to be used by several application instances using Weather::Com::Cached.

You'll need to register at weather.com to to get a free partner id and a license key to be used within all applications that you want to write against weather.com's xoap interface.

http://www.weather.com/services/xmloap.html

CONSTRUCTOR

new(hash or hashref)

This constructor takes the same hash or hashref as Weather::Com::Base does. Please refer to that documentation for further details.

Except from the Weather::Com::Base's parameters this constructor takes a parameter cache which defines the path to a directory into which all cache files will be put.

The cache directory defaults to '.'.

METHODS

That's all the same as for Weather::Com::Base.

SEE ALSO

See also documentation of Weather::Com and Weather::Com::Base.

AUTHOR

Thomas Schnuecker, <thomas@schnuecker.de>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Thomas Schnuecker

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The data provided by weather.com and made accessible by this OO interface can be used for free under special terms. Please have a look at the application programming guide of weather.com!

http://www.weather.com/services/xmloap.html