NAME
Net::WURFL::ScientiaMobile::Cache - Role that all Cache providers must implement to be compatible with the WURFL Cloud Client
SYNOPSIS
DESCRIPTION
This Moo::Role class defines the methods that all Cache providers must implement to be used with the Net::WURFL::ScientiaMobile module.
The following implementations are currently available, but you can write your own:
- Net::WURFL::ScientiaMobile::Cache::Null
- Net::WURFL::ScientiaMobile::Cache::Cache
- Net::WURFL::ScientiaMobile::Cache::Cookie
REQUIRED METHODS
getDevice
my
$capabilities
=
$cache
->getDevice(
$user_agent
);
Get the device capabilities for the given user agent from the cache provider. It accepts the user agent name as a string and returns the capabilities as a hashref, or false if the device wasn't found in cache.
getDeviceFromID
my
$capabilities
=
$cache
->getDeviceFromID(
$wurfl_device_id
);
Get the device capabilities for the given user agent from the cache provider. It accepts the device ID as a string and returns the capabilities as a hashref, or false if the device wasn't found in cache.
setDevice
$cache
->setDevice(
$user_agent
,
$capabilities
);
Stores the given user agent with the given device capabilities in the cache provider for the given time period.
setDeviceFromID
$cache
->setDeviceFromID(
$wurfl_device_id
,
$capabilities
);
Stores the given user agent with the given device capabilities in the cache provider for the given time period.
getMtime
my
$time
=
$cache
->getMtime;
Gets the last loaded WURFL timestamp from the cache provider - this is used to detect when a new WURFL has been loaded on the server.
setMtime
$cache
->setMtime(
$time
);
Sets the last loaded WURFL timestamp in the cache provider.
purge
$cache
->purge;
Deletes all the cached devices and the mtime from the cache provider.
incrementHit
$cache
->incrementHit;
Increments the count of cache hits.
incrementMiss
$cache
->incrementMiss;
Increments the count of cache misses.
incrementError
$cache
->incrementError;
Increments the count of errors.
getCounters
my
$counters
=
$cache
->getCounters;
Returns an array of all the counters.
resetCounters
$cache
->resetCounters;
Resets the counters to zero.
getReportAge
my
$seconds
=
$cache
->getReportAge;
Returns the number of seconds since the counters report was last sent.
resetReportAge
$cache
->resetReportAge;
Resets the report age to zero.
stats
my
$stats
=
$cache
->stats;
Gets statistics from the cache provider like memory usage and number of cached devices.
close
$cache
->
close
;
Close the connection to the cache provider.
SEE ALSO
AUTHOR
Alessandro Ranellucci <aar@cpan.org>
COPYRIGHT & LICENSE
Copyright 2012, ScientiaMobile, Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.