Skip to content

Commit 0806a97

Browse files
committed
docs
1 parent 59d4909 commit 0806a97

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The principal type that FluentCache provides is `CacheBuilder`. `CacheBuilder` i
4545
* If miss, build an object, set it in the cache, and return the object
4646
* If hit, return the object
4747

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.
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.
4949

5050
```php
5151
class Memcache implements \Psr\SimpleCache\CacheInterface {}
@@ -70,7 +70,7 @@ $result = (new CacheBuilder())
7070
return false;
7171
}
7272
return $result->someProperty === 'some value';
73-
});
73+
})
7474
->withBuilder(function() : object {
7575

7676
// build a cacheable object if cache miss
@@ -89,7 +89,14 @@ $result = (new CacheBuilder())
8989
->withLazyEventDispatcher(function(CacheBuilder $this) : EventDispatcherInterface {
9090
return new Dispatcher();
9191
})
92-
92+
93+
// set a custom identifier to track this cache session in downstream event processors
94+
// ...session ids are automatically generated if not provided
95+
// ...session ids are re-generated everytime the immutable cache builder is cloned
96+
->withSessionId('123')
97+
9398
// fetch object from cache or build it and set it in the cache - the caller doesn't care!
9499
->get();
95100
```
101+
102+

0 commit comments

Comments
 (0)