https://github.com/permafrost-dev/laravel-scriptcache
Allows javascript to cache certain information in the laravel cache for a short time.
https://github.com/permafrost-dev/laravel-scriptcache
backend cache javascript laravel laravel-package
Last synced: 2 months ago
JSON representation
Allows javascript to cache certain information in the laravel cache for a short time.
- Host: GitHub
- URL: https://github.com/permafrost-dev/laravel-scriptcache
- Owner: permafrost-dev
- Created: 2019-08-12T10:19:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-12T10:19:16.000Z (almost 7 years ago)
- Last Synced: 2025-07-23T04:29:37.213Z (11 months ago)
- Topics: backend, cache, javascript, laravel, laravel-package
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Laravel ScriptCache
---
This package allows javascript to leverage the laravel cache and store small amounts of data for a limited amount of time, usually 60 seconds.
## Installation
You can install the package via composer:
```bash
composer require permafrost-dev/laravel-scriptcache
```
## Usage
``` javascript
async function setCachedData(value) {
const token = await axios.get('/api/scriptcache?data=' + value);
return token;
}
async function getCachedData(token) {
const result = (await axios.get('/api/scriptcache/'+token));
return result;
}
async function doSomeDataProcessing(dataStr) {
const token = (await setCachedData(dataStr)).data;
const cacheid = token.cache_id;
const cachedDataObject = (await getCachedData(cacheid)).data;
const cachedData = cachedDataObject.data;
console.log('original data: ', dataStr);
console.log('got cached data: ', cachedData);
}
//...cache expires after 60 seconds
```
### Notes
---
The cached data is sanitized prior to storage, and the cache key used is tied to the requesting user to avoid access to other items in the cache.
### Testing
``` bash
composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.