angular-briefcache
Cache factory for Angular with short expirations. Designed for preventing duplication of HTTP requests caused by rapid-fire processes, such as running through routing states.
Usage
Use it anywhere you would use Angular's $cacheFactory
:
angular;
Installation
The briefCache requires Angular and the angular-cache library. These are installed automatically when using npm:
`npm install --save angular-briefcache`
Then include the necessary scripts in your app:
Example Example
You can also use RequireJS to load the modules:
Example using RequireJS Example
Configuration
This cache factory comes with the following settings:
- Each item has a maximum age of 10 seconds.
- Expired items are deleted as they are requested ("passive" removal).
- The entire cache is completely cleared every hour.
These settings can be changed in the briefCacheProvider (prior to Angular bootstrap) or briefCache:
briefCacheProvider; // 8 secondsbriefCacheProvider; // flush the cache every 24 hoursbriefCacheProvider; // search for and deleted expired items briefCache;briefCache; // disables clearing of the entire cache periodicallybriefCache; // use passive removed (the default)
You can disable (or re-enable) the cache prior to Angular bootstrap:
briefCacheProvider;
You can also enable and disable the cache on the fly:
briefCache;briefCache;console;
Contributing
You'll need gulp installed on your machine to run the development tools. Then run gulp
to run all of the tasks and watch the files for changes.
Please add tests and maintain the existing styling when adding and updating the code.
Bugs & Feature Requests
Have an issue or feature request? Please open a new issue.
License
Copyright 2015 Jack Henry & Associates Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.