WeBWorK::EquationCache - create and cache images of TeX equations.

From WeBWorK

Jump to: navigation


WeBWorK::EquationCache - create and cache images of TeX equations.


 my $cache = WeBWorK::EquationCache->new(cacheDB => "/path/to/equationcache.db");
 my $imageName = $cache->lookup('\[3x^2\]');


WeBWorK::PG::EquationCache maintains a list of unique identifiers for TeX strings. The unique identifier is based on an MD5 hash of the TeX string, and a sequence number. Before calcuating the MD5 hash of a TeX string, all whitespace is removed.


The cache database file is a text file consisting of lines of the following form:

 md5_hash     sequence_number     tex_string

Any amount of whitespace may separate the fields. Lines which do not conform to this format are ignored. Any string of characters beginning with `#' and extending to the end of the line is also ignored.



Returns a new EquationCache object. %options must contain the following entries:

 cacheDB => path to image cache database file

If cacheDB is the empty string, don't use a cache file and assume that there are no md5 collisions.


Looks up a TeX string in the database. A unique identifier for the cached image is returned. If necessary, the string is added to the database.