# @dzeio/cache Simple Cache quick key/value server to store cache ## Usage The server is available as a Websocket Server and an HTTP server **Options** Some options are settable and **optionnal** for manipulate how the key works ```jsonc { "options": { "invalidationTags": ["array", "of", "tags", "to", "invalide", "a", "key"], "ttl": 3600, // time to live of the key in seconds "deletable": false // make the element not deletable by the remote (ttl still apply) } } ``` ### Websocket Connect to the websocket server at `/ws` #### Set an item ```jsonc { "type": "set", "key": "key of the item", "scope": "optionnal scope", "value": [{"the": "value", "in": {"any": "format"}, "you": "want"}, 1, true] // other formats // "value": true // "value": 1 // "value": "pouet" // addionnal storage options (see below) // "options": } ``` #### Get an item ```jsonc { "type": "get", "key": "key of the item", "scope": "optionnal scope" } ``` The response will be formatted like this ```json { "value": "value" // the value } ``` ### HTTP Requests #### Set an item send a request to `/:item` or `/:scope/:item` with the method set to `PUT` with the following body: ```jsonc { "value": [{"the": "value", "in": {"any": "format"}, "you": "want"}, 1, true] // other formats // "value": true // "value": 1 // "value": "pouet" // addionnal storage options (see below) // "options": } ``` #### Get an item send a request to `/:item` or `/:scope/:item` with the method set to `GET`. The response will be formatted like this ```json { "value": "value" // the value } ``` #### delete an item send a request to `/:item` or `/:scope/:item` with the method set to `DELETE`. The response will be formatted like this ```json { "existed": true, // return if the element existed "deleted": true // return if the element is deleted (or did not exists in the first place) } ``` /cache/:item /cache/:scope/:item /config/ttl /actions/invalidate?scope=:scope