Skip to content

lstrojny/kesch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A code kata to play around with cache interfaces

Ideas

  • Sensible result handling (differentiating null from not found)
  • Tagging with expiration
  • Use Memcache, Redis, etc. protocols as heavily as possible
  • CSL: caching specific language: store, load, expire, write through, write back, hit, miss
  • Hashing strategies with mutiple storage backends
  • Check and set (Memcache)
  • Load/Save many
  • Storage directors:
    • Size based
    • Hash based
    • Value/key based

Passing a success callback to Cache::load()

<?php
$cache->load('key', function(Kesch\Result $result) {
    if ($result->isHit()) {

    }
});

Returning a Result object

<?php
$result = $cache->load('key');
if ($result->isMiss()) {
    // Regenerate
}

Simply storing a value

<?php
$cache->store('key', 'value');

Storing a value by callback

<?php
$cache->store('key', function() {

});

Storing a value with a success callback for write-through caches

<?php
$cache->store('key', 'value', function($key, $value) {
    // Update another storage
});

Store key along with some tags

<?php
$cache->store(new Kesch\Key('test', array('tag1', 'tag2')), 'value');

Delete values with tags

<?php
$cache->delete(new Kesch\Tags(array('tag1', 'tag2')));

About

Caching code cata

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages