Skip to content

Instantly share code, notes, and snippets.

@jeremeamia
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save jeremeamia/22f1ddbdab5fd2439c2f to your computer and use it in GitHub Desktop.

Select an option

Save jeremeamia/22f1ddbdab5fd2439c2f to your computer and use it in GitHub Desktop.
Why can't we just do a simple cache interface?
<?php
namespace Psr\Cache
{
interface CacheInterface
{
public function get($key, &$isHit); #: mixed
// Note: $isHit is populated with `true` on hit or `false` on miss. This
// is a simple way to distinguish between falsey values and cache misses.
public function has($key); #: bool
public function save($key, $value, $ttl = null); #: bool
public function delete($key); #: bool
}
// This additional interface could be for batching gets/saves, etc.
interface MultiValueCacheInterface
{
public function getMultiple(array $keys); #: array
public function saveMultiple(array $values, $ttl = null); #: bool
public function deleteMultiple(array $keys); #: bool
public function clear(); #: bool
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment