Skip to content

Commit

Permalink
feat(docs): add cache public API examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zhibirc committed Dec 5, 2023
1 parent 5a5fca3 commit b66c084
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ If in general it's usually true, this is very subjective if applied to implement

When the cache becomes full, a cache block or record/entry must be evicted to make room for a new block. The replacement policy determines which block to evict.

Various cache implementations can have slightly different public APIs, however most of them are very consistent in their core capabilities. In the list below there are typical extra features (or just their naming) which can be found in known realisations:

| Member | Type | Description |
|--------|------|-------------------------------------------------------------------------------------|
|`setpop`|method|Sets a value for the given key, but besides that returns evicted object or old value.|
|`peek` |method|Retrieves the value associated with the given key, doesn't update access information.|
Various cache implementations can have slightly different public APIs, however most of them are very consistent in their core capabilities. In the list below there are typical extra features which can be found in known cache realisations (as part of their public API):

| Member | Type | Description |
|---------|--------|-------------------------------------------------------------------------------------|
|`size` |property|Number of entries/items/records actually stored in cache ($size <= capacity$). |
|`from` |static |Instantiate cache with data (usually key-value structure). |
|`setpop` |method |Sets a value for the given key, but besides that returns evicted object or old value.|
|`peek` |method |Retrieves the value associated with the given key, doesn't update access information.|
|`forEach`|method |Convenient helper methods implementing the ability to iterate on cache data. |
|`keys` |method | |
|`values` |method | |
|`entries`|method | |

0 comments on commit b66c084

Please sign in to comment.