You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,59 @@ Assuming you have setup Composer's autoloader, FluentCache can be found in the `
37
37
38
38
## Usage
39
39
40
+
The principal type that FluentCache provides is `CacheBuilder`. `CacheBuilder` is an immutable object that takes references to a cache and anonymous functions to generate a cache key, build cacheable objects, validate results, and hook an event dispatcher.
41
+
42
+
`CacheBuilder` handles the responsibility for, and obfuscates, the steps required to orchestrate the most common scenario for handling cached data:
43
+
44
+
* Check the cache for an object
45
+
* If miss, build an object, set it in the cache, and return the object
46
+
* If hit, return the object
47
+
48
+
Managing these steps, choosing what to profile, when to validate, or other cache-specific decision making isn't the responsibility of the calling code: the caller just wants to _get_ an object, it shouldn't care if it comes from a cache, if the data is stale, or the object is built for the first time. `CacheBuilder` separates this concern and encapsulates it, exposing custom logic hooks for reasonable flexibility.
49
+
40
50
```php
51
+
class Memcache implements \Psr\SimpleCache\CacheInterface {}
52
+
53
+
class Dispatcher implements \Psr\EventDispatcher\EventDispatcherInterface {}
0 commit comments