2. What is CHI?
• Cache Handling Interface
• Standard interface and implementation for Perl
caching ... like 'DBI for caching'
• Caching = “Get and set key/values with expiration”
4. What’s it good for?
• Implement standard caching features in a single place
• Namespaces • Logging
• Serialization • Statistics collection
• Multilevel caches • Error handling
• Probablistic expiration • Compression
• Max size and discard • Configuration
• Make new cache backends trivial to create
13. Why is compute() better?
• Less typing
• Background recomputation *
(return old value immediately, recompute in background)
• Can measure compute time and thus cache utility
* - theoretical, not yet implemented
14. Cache utility
HR = hit rate
Cget = cost of get
Cset = cost of set
Ccompute = cost of compute
Cget + (Ccompute + Cset) / HR
Utility = -------------------------------
Ccompute
16. Stats collected per namespace
• # hits, misses, and sets hit rate
• avg cost of get, set, and compute (ms)
• avg key and value size
17. Resources
• Get CHI from CPAN -
http://search.cpan.org/perldoc?CHI
• Search for drivers -
http://cpan.uwinnipeg.ca/search?query=CHI::Driver
• Subscribe to perl-cache mailing list -
http://groups.google.com/group/perl-cache-discuss
18.
19. Benchmarks
Description Get time Set time
CHI::Driver::MemoryRaw 0.019ms 0.036ms
CHI::Driver::Memory 0.042ms 0.066ms
CHI::Driver::BerkeleyDB 0.052ms 0.073ms
CHI::Driver::FastMmap 0.057ms 0.087ms
CHI::Driver::DBI (sqlite) 0.112ms 1.659ms
CHI::Driver::File 0.118ms 1.138ms
CHI::Driver::Memcached::Fast 0.138ms 0.178ms
CHI::Driver::Memcached::libm 0.151ms 0.202ms
CHI::Driver::DBI (mysql) 0.236ms 0.273ms
CHI::Driver::Memcached 0.279ms 0.235ms