@travetto/cache 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +6 -11
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  <!-- This file was generated by @travetto/doc and should not be modified directly -->
2
- <!-- Please modify https://github.com/travetto/travetto/tree/main/module/cache/DOC.ts and execute "npx trv doc" to rebuild -->
2
+ <!-- Please modify https://github.com/travetto/travetto/tree/main/module/cache/DOC.tsx and execute "npx trv doc" to rebuild -->
3
3
  # Caching
4
+
4
5
  ## Caching functionality with decorators for declarative use.
5
6
 
6
7
  **Install: @travetto/cache**
@@ -24,9 +25,7 @@ npm install @travetto/model-{provider}
24
25
 
25
26
  yarn add @travetto/model-{provider}
26
27
  ```
27
-
28
28
  Currently, the following are packages that provide [Expiry](https://github.com/travetto/travetto/tree/main/module/model/src/service/expiry.ts#L11):
29
-
30
29
  * [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") - @travetto/model: [FileModelService](https://github.com/travetto/travetto/tree/main/module/model/src/provider/file.ts#L51), [MemoryModelService](https://github.com/travetto/travetto/tree/main/module/model/src/provider/memory.ts#L54)
31
30
  * [DynamoDB Model Support](https://github.com/travetto/travetto/tree/main/module/model-dynamodb#readme "DynamoDB backing for the travetto model module.") - @travetto/model-dynamodb
32
31
  * [Elasticsearch Model Source](https://github.com/travetto/travetto/tree/main/module/model-elasticsearch#readme "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.") - @travetto/model-elasticsearch
@@ -69,13 +68,11 @@ export class Worker {
69
68
  }
70
69
  ```
71
70
 
72
- ### [@Cache](https://github.com/travetto/travetto/tree/main/module/cache/src/decorator.ts#L13)
73
-
71
+ ### Cache
74
72
  The [@Cache](https://github.com/travetto/travetto/tree/main/module/cache/src/decorator.ts#L13) decorator supports configurations on:
75
-
76
-
77
73
  * `name` the field name of the current class which points to the desired cache source.
78
- * `config` the additional/optional config options, on a per invocation basis
74
+ * `config` the additional/optional config options, on a per invocation basis
75
+
79
76
  * `keySpace` the key space within the cache. Defaults to class name plus method name.
80
77
  * `key` the function will use the inputs to determine the cache key, defaults to all params `JSON.stringify`ied
81
78
  * `params` the function used to determine the inputs for computing the cache key. This is an easier place to start to define what parameters are important in ,caching. This defaults to all inputs.
@@ -84,8 +81,7 @@ The [@Cache](https://github.com/travetto/travetto/tree/main/module/cache/src/dec
84
81
  * `serialize` the function to execute before storing a cacheable value. This allows for any custom data modification needed to persist as a string properly.
85
82
  * `reinstate` the function to execute on return of a cached value. This allows for any necessary operations to conform to expected output (e.g. re-establishing class instances, etc.). This method should not be used often, as the return values of the methods should naturally serialize to/from `JSON` and the values should be usable either way.
86
83
 
87
- ### [@EvictCache](https://github.com/travetto/travetto/tree/main/module/cache/src/decorator.ts#L40)
88
-
84
+ ### EvictCache
89
85
  Additionally, there is support for planned eviction via the [@EvictCache](https://github.com/travetto/travetto/tree/main/module/cache/src/decorator.ts#L40) decorator. On successful execution of a method with this decorator, the matching keySpace/key value will be evicted from the cache. This requires coordination between multiple methods, to use the same `keySpace` and `key` to compute the expected key.
90
86
 
91
87
  **Code: Using decorators to cache/evict user access**
@@ -122,7 +118,6 @@ export class UserService {
122
118
  ```
123
119
 
124
120
  ## Extending the Cache Service
125
-
126
121
  By design, the [CacheService](https://github.com/travetto/travetto/tree/main/module/cache/src/service.ts#L29) relies solely on the [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") module. Specifically on the [Expiry](https://github.com/travetto/travetto/tree/main/module/model/src/service/expiry.ts#L11). This combines basic support for CRUD as well as knowledge of how to manage expirable content. Any model service that honors these contracts is a valid candidate to power the [CacheService](https://github.com/travetto/travetto/tree/main/module/cache/src/service.ts#L29). The [CacheService](https://github.com/travetto/travetto/tree/main/module/cache/src/service.ts#L29) is expecting the model service to be registered using the @travetto/cache:model:
127
122
 
128
123
  **Code: Registering a Custom Model Source**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cache",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Caching functionality with decorators for declarative use.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,12 +25,12 @@
25
25
  "directory": "module/cache"
26
26
  },
27
27
  "dependencies": {
28
- "@travetto/di": "^3.0.2",
29
- "@travetto/model": "^3.0.2"
28
+ "@travetto/di": "^3.0.3",
29
+ "@travetto/model": "^3.0.3"
30
30
  },
31
31
  "peerDependencies": {
32
- "@travetto/test": "^3.0.2",
33
- "@travetto/transformer": "^3.0.2"
32
+ "@travetto/test": "^3.0.3",
33
+ "@travetto/transformer": "^3.0.3"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "@travetto/transformer": {