11# ` cache `
22
3- [ ![ version] ( https://img.shields.io/github/package-json/v/NodeSecure/Cli?filename=workspaces%cache %2Fpackage.json&style=for-the-badge )] ( https://www.npmjs.com/package/@nodesecure/cache )
3+ [ ![ version] ( https://img.shields.io/github/package-json/v/NodeSecure/Cli?filename=workspaces%2Fcache %2Fpackage.json&style=for-the-badge )] ( https://www.npmjs.com/package/@nodesecure/cache )
44[ ![ OpenSSF
55Scorecard] ( https://api.securityscorecards.dev/projects/github.com/NodeSecure/cli/badge?style=for-the-badge )] ( https://api.securityscorecards.dev/projects/github.com/NodeSecure/cli )
66[ ![ mit] ( https://img.shields.io/github/license/NodeSecure/Cli?style=for-the-badge )] ( https://github.com/NodeSecure/cli/blob/master/LICENSE )
@@ -11,7 +11,7 @@ Caching layer for NodeSecure CLI and server, handling configuration, analysis pa
1111
1212## Requirements
1313
14- - [ Node.js] ( https://nodejs.org/en/ ) v20 or higher
14+ - [ Node.js] ( https://nodejs.org/en/ ) v24 or higher
1515
1616## Getting Started
1717
@@ -43,121 +43,5 @@ await cache.setRootPayload(payload);
4343
4444## API
4545
46- ### ` updateConfig(config: AppConfig): Promise<void> `
47-
48- Stores a new configuration object in the cache.
49-
50- ### ` getConfig(): Promise<AppConfig> `
51-
52- Retrieves the current configuration object from the cache.
53-
54- ### ` updatePayload(packageName: string, payload: Payload): void `
55-
56- Saves an analysis payload for a given package.
57-
58- ** Parameters** :
59- - ` pkg ` (` string ` ): Package name (e.g., ` "@nodesecure/scanner@6.0.0" ` ).
60- - ` payload ` (` object ` ): The analysis result to store.
61-
62- > [ !NOTE]
63- > Payloads are stored in the user's home directory under ` ~/.nsecure/payloads/ `
64-
65- ### ` getPayload(packageName: string): Payload `
66-
67- Loads an analysis payload for a given package.
68-
69- ** Parameters** :
70- ` pkg ` (` string ` ): Package name.
71-
72- ### ` availablePayloads(): string[] `
73-
74- Lists all available payloads (package names) in the cache.
75-
76- ### ` getPayloadOrNull(packageName: string): Payload | null `
77-
78- Loads an analysis payload for a given package, or returns ` null ` if not found.
79-
80- ** Parameters** :
81-
82- - ` pkg ` (` string ` ): Package name.
83-
84- Returns ` null ` if not found.
85-
86- ### ` updatePayloadsList(payloadsList: PayloadsList): Promise<void> `
87-
88- Updates the internal MRU/LRU and available payloads list.
89-
90- ** Parameters** :
91-
92- - ` payloadsList ` (` object ` ): The new payloads list object.
93-
94- ### ` payloadsList(): Promise<PayloadsList> `
95-
96- Retrieves the current MRU/LRU and available payloads list.
97-
98- ### ` initPayloadsList(options: InitPayloadListOptions = {}): Promise<void> `
99-
100- Initializes the payloads list, optionally resetting the cache.
101-
102- ** Parameters** :
103-
104- - ` options ` (` object ` , * optional* ):
105- - ` logging ` (` boolean ` , default: ` true ` ): Enable logging.
106- - ` reset ` (` boolean ` , default: ` false ` ): If ` true ` , reset the cache before initializing.
107-
108- ### ` removePayload(packageName: string): void `
109-
110- Removes a payload for a given package from the cache.
111-
112- ** Parameters** :
113- - ` pkg ` (` string ` ): Package name.
114-
115- ### ` removeLastMRU(): Promise<PayloadsList> `
116-
117- Removes the least recently used payload if the MRU exceeds the maximum allowed.
118-
119- ### ` setRootPayload(payload: Payload, options: SetRootPayloadOptions = {}): Promise<void> `
120-
121- Sets a new root payload, updates MRU/LRU, and manages cache state.
122-
123- ** Parameters** :
124-
125- - ` payload ` (` object ` ): The analysis result to set as root.
126- - ` options ` (` object ` ):
127- - ` logging ` (` boolean ` , default: ` true ` ): Enable logging.
128- - ` local ` (` boolean ` , default: ` false ` ): Mark the payload as local.
129-
130- ## Interfaces
131-
132- ``` ts
133- interface AppConfig {
134- defaultPackageMenu: string ;
135- ignore: {
136- flags: Flag [];
137- warnings: WarningName [];
138- };
139- theme? : " light" | " dark" ;
140- disableExternalRequests: boolean ;
141- }
142-
143- interface PayloadsList {
144- mru: string [];
145- lru: string [];
146- current: string ;
147- availables: string [];
148- lastUsed: Record <string , number >;
149- root: string | null ;
150- }
151-
152- interface LoggingOption {
153- logging? : boolean ;
154- }
155-
156- interface InitPayloadListOptions extends LoggingOption {
157- reset? : boolean ;
158- }
159-
160- interface SetRootPayloadOptions extends LoggingOption {
161- local? : boolean ;
162- }
163- ```
46+ - [ AppCache] ( ./docs/AppCache.md )
47+ - [ FilePersistanceProvider] ( ./docs/FilePersistanceProvider.md )
0 commit comments