https://github.com/lstrojny/kesch
Caching code cata
https://github.com/lstrojny/kesch
Last synced: 3 months ago
JSON representation
Caching code cata
- Host: GitHub
- URL: https://github.com/lstrojny/kesch
- Owner: lstrojny
- Created: 2012-08-04T15:38:53.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-08-04T16:47:58.000Z (almost 13 years ago)
- Last Synced: 2025-03-10T07:35:42.824Z (3 months ago)
- Language: PHP
- Size: 97.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
load('key', function(Kesch\Result $result) {
if ($result->isHit()) {}
});
```### Returning a Result object
```php
load('key');
if ($result->isMiss()) {
// Regenerate
}
```### Simply storing a value
```php
store('key', 'value');
```### Storing a value by callback
```php
store('key', function() {});
```### Storing a value with a success callback for write-through caches
```php
store('key', 'value', function($key, $value) {
// Update another storage
});
```### Store key along with some tags
```php
store(new Kesch\Key('test', array('tag1', 'tag2')), 'value');
```### Delete values with tags
```php
delete(new Kesch\Tags(array('tag1', 'tag2')));
```