Check out the demo for a quick introduction, or continue on down for more detailed information.
The goal of the project is to solve a general problem, not satisfy a specific scenario.
See TRANSITION.md for upgrading from 1.x.x to 2.x.x.
// Angular's provided $cacheFactory
app.service('myService', function ($cacheFactory) {
// This is all you can do with $cacheFactory
$cacheFactory('myNewCache', { capacity: 1000 }); // This cache can hold 1000 items
});
// Smarter caching with $angularCacheFactory
app.service('myService', function ($angularCacheFactory) {
$angularCacheFactory('myNewCache', {
capacity: 1000, // This cache can hold 1000 items,
maxAge: 90000, // Items added to this cache expire after 15 minutes
deleteOnExpire: 'aggressive', // Items will be actively deleted when they expire
cacheFlushInterval: 3600000, // This cache will clear itself every hour,
storageMode: 'localStorage' // This cache will sync itself with localStorage,
onExpire: function (key, value) {
// This callback is executed when the item specified by "key" expires.
// At this point you could retrieve a fresh value for "key"
// from the server and re-insert it into the cache.
}
});
});
- Demo
- Configuration Parameters
- $angularCacheFactoryProvider
- $angularCacheFactory
- AngularCache
- Status
- Download
- Install
- Usage
- Changelog
- Contributing
- License
Type: String
Default: "none"
Possible Values:
"none"
- The cache will not sync itself with web storage."localStorage"
- Sync withlocalStorage
"sessionStorage"
- Sync withsessionStorage
Description: Configure the cache to sync itself with localStorage
or sessionStorage
. The cache will re-initialize itself from localStorage
or sessionStorage
on page refresh.
Usage:
$angularCacheFactory('newCache', {
storageMode: 'localStorage'
}); // this cache will sync itself to localStorage
See Using angular-cache with localStorage.
Type: Object
Default: null
Description: When storageMode
is set to "localStorage"
or "sessionStorage"
angular-cache will default to using the global localStorage
and sessionStorage
objects. The angular-cache localStorageImpl
and sessionStorageImpl
configuration parameters allow you to tell angular-cache which implementation of localStorage
or sessionStorage
to use. This is useful when you don't want to override the global storage objects or when using angular-cache in a browser that doesn't support localStorage
or sessionStorage
.
Usage:
$angularCacheFactory('newCache', {
localStorageImpl: myLocalStorageImplementation,
storageMode: 'localStorage'
});
$angularCacheFactory('otherCache', {
localStorageImpl: mySessionStorageImplementation,
storageMode: 'sessionStorage'
});
Note: If angular-cache doesn't detect a global localStorage
or sessionStorage
and you don't provide a polyfill, then syncing with web storage will be disabled. It is up to the developer to provide a polyfill for browsers that don't support localStorage
and sessionStorage
. Any implementation of localStorage
and sessionStorage
provided to angular-cache must implement at least the setItem
, getItem
, and removeItem
methods.
See Using angular-cache with localStorage.
Type: Number
Default: null
Description: Set a default maximum lifetime on all items added to the cache. They will be removed aggressively or passively or not at all depending on the value of deleteOnExpire
(see below). Can be configured on a per-item basis for greater specificity.
Usage:
$angularCacheFactory('newCache', { maxAge: 36000 });
Type: String
Default: "none"
Possible Values:
"none"
- Items will not be removed from the cache even if they have expired."passive"
- Items will be deleted if they are requested after they have expired, resulting in a miss."aggressive"
- Items will be deleted as soon as they expire.
Description: maxAge
must be set in order for "passive"
or "aggressive"
to have any effect. Can be configured on a per-item basis for greater specificity.
Usage:
$angularCacheFactory('newCache', {
maxAge: 36000,
deleteOnExpire: 'aggressive'
});
Type: Number
Default: null
Description: Set the cache to periodically clear itself.
Usage:
$angularCacheFactory('newCache', { cacheFlushInterval: 57908 });
Type: Function
Default: null
Description: A callback function to be executed when an item expires.
In passive delete mode the cache doesn't know if an item has expired until the item is requested, at which point the cache checks to see if the item has expired. If the item has expired then it is immediately removed from the cache, resulting in a "miss".
If you specify a global "onExpire" callback function, the cache will execute this function when it is discovered the item has expired, passing to the callback the key and value of the expired item.
When you actually request the expired item via myCache.get('someKey')
you can also pass a second argument to get()
specifying a callback that your cache's "onExpire" callback can execute when it finishes. For example:
Usage:
var newCache = $angularCacheFactory('newCache', {
maxAge: 1000, // Items expire after 1 second, but we don't know it until the item is requested
onExpire: function (key, value, done) {
// "onExpire" callback for the cache.
// The third optional parameter "done", is the second argument passed to `get()` as described above
console.log(key + ' expired!');
// Retrieve fresh value for "key" from server, of course you'll need to figure out
// what the url is if key != url
$http.get(key).success(function (data) {
$angularCacheFactory.get('newCache').put(key, data);
done(data); // Execute the "done" callback specified in the `get()` call
});
});
});
newCache.put('denver', 'broncos');
// wait a few seconds
var value = newCache.get('denver', function (value) {
// here value is defined, because we retrieved it from the server
});
// here value is undefined because the item with
// the key "denver" has expired and was deleted from the
// cache when we requested it. The callback passed to
// "get()" will receive the new value for 'denver' which
// will be retrieved from the server. This callback
// is the "done" callback executed by the "onExpire"
// callback specified when we created the cache.
Another usage:
// We don't specify an "onExpire" callback for this cache
var newCache = $angularCacheFactory('newCache', {
maxAge: 1000, // Items expire after 1 second, but we don't know it until the item is requested
});
newCache.put('denver', 'broncos');
// wait a few seconds
// In this cache the callback is immediately executed when
// the cache discovers that 'denver' has expired, and the
// callback is passed the key and value of the expired item.
// Here you could retrieve a new value for 'denver' from
// the server or decide to keep the old value and re-insert
// it into the cache. Specifying an "onExpire" callback for
// the cache is a good way to stay DRY.
var value = newCache.get('denver', function (key, value) {
if (isGoodThisYear(key, value)) {
newCache.put(key, value);
} else {
$http.get(key).success(function (data) {
newCache.put(key, data);
});
}
});
In aggressive delete mode you can't pass a second parameter to get()
because your "onExpire" callback for the cache has already been executed for expired items.
Usage:
var newCache = $angularCacheFactory('newCache', {
maxAge: 1000, // Items expire after 1 second and are immediately deleted
onExpire: function (key, value) {
// "onExpire" callback for the cache.
// The third optional parameter "done", is the second argument passed to `get()` as described above
console.log(key + ' expired!');
// Retrieve fresh value for "key" from server, of course you'll need to figure out
// what the url is if key != url
$http.get(key).success(function (data) {
$angularCacheFactory.get('newCache').put(key, data);
});
});
});
newCache.put('denver', 'broncos');
// wait a few seconds, during which time the "onExpire" callback is automatically executed
newCache.get('denver'); // 'broncos' or whatever was returned by the server in the "onExpire" callback
Description: Provider for $angularCacheFactory
.
Description: Set the default configuration for all caches created by $angularCacheFactory
.
Usage:
app.module('app', ['jmdobry.angular-cache'])
.config(function ($angularCacheFactoryProvider) {
$angularCacheFactoryProvider.setCacheDefaults({
maxAge: 360000,
deleteOnExpire: 'aggressive'
});
})
.run(function ($angularCacheFactory) {
var info = $angularCacheFactory.info();
console.log(info.cacheDefaults); // output below
/*
{
capacity: Number.MAX_VALUE,
maxAge: 360000,
deleteOnExpire: 'aggressive',
onExpire: null,
cacheFlushInterval: null,
storageMode: 'none',
localStorageImpl: null,
sessionStorageImpl: null
}
*/
var newCache = $angularCacheFactory('newCache');
newCache.info().maxAge; // 360000
newCache.info().deleteOnExpire; // "aggressive"
});
Description: Factory function for producing instances of AngularCache
.
Description: Return the set of keys associated with all caches in $angularCacheFactory
.
Usage:
$angularCacheFactory.keySet();
Description: Return an array of the keys associated with all caches in $angularCacheFactory
.
Usage:
$angularCacheFactory.keys();
Description: Object produced by invocations of $angularCacheFactory()
.
Description: Dynamically configure a cache.
See Dynamically configure a cache.
Parameters:
Type: Object
Default:
{}
Description: Hash of configuration options to apply to the cache.
Type: Boolean
Default:
false
Description: If
true
, any configuration options not specified inoptions
will be set to their defaults.
Usage:
$angularCacheFactory.get('someCache').setOptions({ capacity: 4500 });
Returns: Object
Description: Return the set of keys of all items the cache.
Usage:
$angularCacheFactory.get('someCache').keySet();
Returns: Array
Description: Return an array of the keys of all items in the cache.
Usage:
AngularCache.keys();
Version | Branch | Build status | Test Coverage |
---|---|---|---|
2.0.0-SNAPSHOT | master | Test Coverage | |
2.0.0-SNAPSHOT | develop | ||
2.0.0-SNAPSHOT | all |
| Type | File | Size | | ------------- | ----------------- | ------------------- | ---- | | Production | angular-cache-2.0.0-SNAPSHOT.min.js | 6 KB | | Development | angular-cache-2.0.0-SNAPSHOT.js | 34 KB |
bower install angular-cache
Include src/angular-cache.js
on your web page after angular.js
.
Get angular-cache from the Download section and include it on your web page after angular.js
.
- Load angular-cache
- Create a cache
- Using angular-cache with localStorage
- Using angular-cache with $http
- Dynamically configure a cache
- Retrieve a cache
- Retrieve items
- Add items
- Remove items
- Clear all items
- Destroy a cache
- Get info about a cache
- API Documentation
Make sure angular-cache is included on your web page after angular.js
.
angular.module('myApp', ['jmdobry.angular-cache']);
See angular-cache
app.service('myService', function ($angularCacheFactory) {
// create a cache with default settings
var myCache = $angularCacheFactory('myCache');
// create an LRU cache with a capacity of 10
var myLRUCache = $angularCacheFactory('myLRUCache', {
capacity: 10
});
// create a cache whose items have a maximum lifetime of 10 minutes
var myTimeLimitedCache = $angularCacheFactory('myTimeLimitedCache', {
maxAge: 600000,
onExpire: function (key, value, done) {
// This callback is executed during a call to "get()" and the requested item has expired.
// Receives the key and value of the expired item and a third argument, "done", which is
// a callback function passed as the second argument to "get()".
// See the "onExpire" configuration option discussed above.
// do something, like get a fresh value from the server and put it into the cache
if (done && typeof done === 'function') {
done(); // pass whatever you want into done()
}
}
});
// create a cache whose items have a maximum lifetime of 10 minutes which are immediately deleted upon expiration
var myAggressiveTimeLimitedCache = $angularCacheFactory('myAggressiveTimeLimitedCache', {
maxAge: 600000,
onExpire: function (key, value) {
// This callback is executed right when items expire. Receives the key and value of expired items.
// See the "onExpire" configuration option discussed above.
// do something, like get a fresh value from the server and put it into the cache
}
});
// create a cache that will clear itself every 10 minutes
var myIntervalCache = $angularCacheFactory('myIntervalCache', {
cacheFlushInterval: 600000
});
// create an cache with all options
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
capacity: 10, // This cache can only hold 10 items.
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
storageMode: 'localStorage', // This cache will sync itself with `localStorage`.
localStorageImpl: myAwesomeLSImpl // This cache will use a custom implementation of localStorage.
});
});
Using angular-cache in browsers that support localStorage:
app.service('myService', function ($angularCacheFactory) {
// This cache will sync itself with localStorage if it exists, otherwise it won't. Every time the
// browser loads this app, this cache will attempt to initialize itself with any data it had
// already saved to localStorage (or sessionStorage if you used that).
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
storageMode: 'localStorage' // This cache will sync itself with `localStorage`.
});
});
Using angular-cache in browsers that DON'T support localStorage:
Option 1 - Do nothing (the localStorage sync feature will be disabled)
Option 2 - Create/use a polyfill that provides the global localStorage
and sessionStorage
objects. angular-cache will attempt to use these if it finds them.
Option 3 - Tell angular-cache exactly which polyfill to use (also useful if you just want to use your own implementation/wrapper for localStorage):
app.service('myService', function ($angularCacheFactory) {
var localStoragePolyfill = {
getItem: function (key) { ... },
setItem: function (key, value) { ... },
removeItem: function (key) { ... }
};
// Always use the polyfill
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
storageMode: 'localStorage', // This cache will sync itself with `localStorage`.
localStorageImpl: localStoragePolyfill // angular-cache will use this polyfill instead of looking for localStorage
});
// Conditionally use the polyfill
var options = {
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
storageMode: 'localStorage' // This cache will sync itself with `localStorage`.
};
if (!window.localStorage) {
options.localStorageImpl = localStoragePolyfill;
}
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', options);
});
Documentation on the interface that must be implementated by any localStorage/sessionStorage polyfill used by angular-cache can be found on the W3C Recommendation page for webstorage. The interface itself looks like:
interface Storage {
readonly attribute unsigned long length;
DOMString? key(unsigned long index);
getter DOMString getItem(DOMString key);
setter creator void setItem(DOMString key, DOMString value);
deleter void removeItem(DOMString key);
void clear();
};
angular-cache cares only about these three methods:
One developer suggested using store.js–a wrapper and polyfill for localStorage. However, store.js has its own API that doesn't match that of the webstorage spec, so if you want to use store.js or any other 3rd-party polyfill then you'll need to create a wrapper for it if it doesn't have the same API as localStorage
. For example:
var storeJsToStandard {
getItem: store.get,
setItem: store.set,
removeItem: store.remove
};
$angularCacheFactory('myNewCache', {
storageMode: 'localStorage',
localStorageImpl: storeJsToStandard
});
Note The downside of letting $http handle caching for you is that it caches the responses (in string form) to your requests–not the JavaScript Object parsed from the response body. This means you can't interact with the data in the cache used by $http
. See below for how to handle the caching yourself–giving you more control and the ability to interact with the cache (use it as a data store).
Configure $http
to use a cache created by $angularCacheFactory
by default:
app.run(function ($http, $angularCacheFactory) {
$angularCacheFactory('defaultCache', {
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
});
$http.defaults.cache = $angularCacheFactory.get('defaultCache');
});
app.service('myService', function ($http) {
return {
getDataById: function (id) {
var deferred = $q.defer(),
start = new Date().getTime();
$http.get('api/data/' + id, {
cache: true
}).success(function (data) {
console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
deferred.resolved(data);
});
return deferred.promise;
}
};
});
app.controller('myCtrl', function (myService) {
myService.getDataById(1)
.then(function (data) {
// e.g. "time taken for request: 2375ms"
// Data returned by this next call is already cached.
myService.getDataById(1)
.then(function (data) {
// e.g. "time taken for request: 1ms"
});
});
});
Tell $http
to use a cache created by $angularCacheFactory
for a specific request:
app.service('myService', function ($http, $angularCacheFactory) {
$angularCacheFactory('dataCache', {
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
});
return {
getDataById: function (id) {
var deferred = $q.defer(),
start = new Date().getTime();
$http.get('api/data/' + id, {
cache: $angularCacheFactory.get('dataCache')
}).success(function (data) {
console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
deferred.resolved(data);
});
return deferred.promise;
}
};
});
app.controller('myCtrl', function (myService) {
myService.getDataById(1)
.then(function (data) {
// e.g. "time taken for request: 2375ms"
// Data returned by this next call is already cached.
myService.getDataById(1)
.then(function (data) {
// e.g. "time taken for request: 1ms"
});
});
});
Do your own caching while using the $http service:
app.service('myService', function ($http, $angularCacheFactory) {
$angularCacheFactory('dataCache', {
maxAge: 90000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
});
return {
getDataById: function (id) {
var deferred = $q.defer(),
start = new Date().getTime(),
dataCache = $angularCacheFactory.get('dataCache');
// Now that control of inserting/removing from the cache is in our hands,
// we can interact with the data in "dataCache" outside of this context,
// e.g. Modify the data after it has been returned from the server and
// save those modifications to the cache.
if (dataCache.get(id)) {
deferred.resolve(dataCache.get(id));
} else {
$http.get('api/data/' + id).success(function (data) {
console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
deferred.resolved(data);
});
}
return deferred.promise;
}
};
});
app.controller('myCtrl', function (myService) {
myService.getDataById(1)
.then(function (data) {
// e.g. "time taken for request: 2375ms"
// Data returned by this next call is already cached.
myService.getDataById(1)
.then(function (data) {
// e.g. "time taken for request: 1ms"
});
});
});
app.service('myService', function ($angularCacheFactory) {
// create a cache with default settings
var cache = $angularCacheFactory('cache', {
capacity: 100,
maxAge: 30000
});
// Add 50 items here, for example
cache.info(); // { ..., size: 50, capacity: 100, maxAge: 3000, ... }
cache.setOptions({
capacity: 30
});
cache.info(); // { ..., size: 30, capacity: 30, maxAge: 3000, ... }
// notice that only the 30 most recently added items remain in the cache because
// the capacity was reduced.
// setting the second parameter to true will cause the cache's configuration to be
// reset to defaults before the configuration passed into setOptions() is applied to
// the cache
cache.setOptions({
cacheFlushInterval: 5500
}, true);
cache.info(); // { ..., size: 30, cacheFlushInterval: 5500,
// capacity: 1.7976931348623157e+308, maxAge: null, ... }
cache.put('someItem', 'someValue', { maxAge: 12000, deleteOnExpire: 'aggressive' });
cache.info('someItem'); // { timestamp: 12345678978, maxAge: 12000, deleteOnExpire: 'aggressive', isExpired: false }
});
app.service('myOtherService', function ($angularCacheFactory) {
var myCache = $angularCacheFactory.get('myCache');
});
myCache.get('someItem'); // { name: 'John Doe' });
// if the item is not in the cache or has expired
myCache.get('someMissingItem'); // undefined
See AngularCache#get
myCache.put('someItem', { name: 'John Doe' });
myCache.get('someItem'); // { name: 'John Doe' });
Give a specific item a maximum age
// The maxAge given to this item will override the maxAge of the cache, if any was set
myCache.put('someItem', { name: 'John Doe' }, { maxAge: 10000 });
myCache.get('someItem'); // { name: 'John Doe' });
// wait at least ten seconds
setTimeout(function() {
myCache.get('someItem'); // undefined
}, 15000); // 15 seconds
See AngularCache#put
myCache.put('someItem', { name: 'John Doe' });
myCache.remove('someItem');
myCache.get('someItem'); // undefined
myCache.put('someItem', { name: 'John Doe' });
myCache.put('someOtherItem', { name: 'Sally Jean' });
myCache.removeAll();
myCache.get('someItem'); // undefined
myCache.get('someOtherItem'); // undefined
myCache.destroy();
myCache.get('someItem'); // Will throw an error - Don't try to use a cache after destroying it!
$angularCacheFactory.get('myCache'); // undefined
myCache.put("1", "someValue");
myCache.info(); // { id: 'myCache', size: 1 }
myCache.keys(); // ["1"]
myCache.keySet(); // { "1": "1" }
- Swapped
aggressiveDelete
option fordeleteOnExpire
option. #30, #47 - Changed
$angularCacheFactory.info()
to return an object similar toAngularCache.info()
#45 - Namespaced angular-cache module under
jmdobry
so it is now "jmdobry.angular-cache". #42 - Substituted
localStorageImpl
andsessionStorageImpl
options for juststorageImpl
option.
- Added ability to set global cache defaults in $angularCacheFactoryProvider. #55
- cacheFlushInterval doesn't clear web storage when storageMode is used. #52
- AngularCache#info(key) should return 'undefined' if the key isn't in the cache #53
- Refactored angular-cache
setOptions()
internals to be less convoluted and to have better validation. #46
- Added AngularCache#info(key) #43
- Fixed #39, #44, #49, #50
- Added onExpire callback hook #27
- Added
$angularCacheFactory.removeAll()
and$angularCacheFactory.clearAll()
convenience methods #37, #38
- Fixed #36
- Closed #31 (Improved documentation)
- Closed #32
- Added localStorage feature #26, #29
- Fixed #25
- Added a changelog #13
- Added documentation for installing with bower
- Added ability to set option
aggressiveDelete
when creating cache and when adding items - Cleaned up README.md
- Switched the demo to use Bootstrap 3
- Added CONTRIBUTING.md #22
- Cleaned up meta data in bower.json and package.json
- Added .jshintrc
- Cleaned up the docs a bit
bower.json
now usessrc/angular-cache.js
instead of the versioned output files #21- From now on the tags for the project will be named using semver
- Added
AngularCache.setOptions()
, the ability to dynamically change the configuration of a cache #20 - Added
AngularCache.keys()
, which returns an array of the keys in a cache #19 - Added
AngularCache.keySet()
, which returns a hash of the keys in a cache #19
- Added
angular-cache
to bower registry #7 - Created a working demo #9 #17
- Fixed the size not being reset to 0 when the cache clears itself #14 #16
- Added
$angularCacheFactory.keys()
, which returns an array of the keys (the names of the caches) in $angularCacheFactory #18 - Added
$angularCacheFactory.keySet()
, which returns a hash of the keys (the names of the caches) in $angularCacheFactory #18
- Got the project building on TravisCI
- Renamed the project to
angular-cache
#5
- Added a roadmap to README.md #4
- Clarify usage documentation #3
- Wrote unit tests #2
- Added Grunt build tasks #1
- Make sure you aren't submitting a duplicate issue.
- Carefully describe how to reproduce the problem.
- Expect prompt feedback.
- Checkout a new branch based on
develop
and name it to what you intend to do:- Example:
$ git checkout -b BRANCH_NAME
- Use one branch per fix/feature
- Prefix your branch name with
feature-
orfix-
appropriately.
- Example:
- Make your changes
- Make sure to provide a spec for unit tests
- Run your tests with either
karma start
orgrunt test
- Make sure the tests pass
- Commit your changes
- Please provide a git message which explains what you've done
- Commit to the forked repository
- Make a pull request
- Make sure you send the PR to the
develop
branch - Travis CI is watching you!
- Make sure you send the PR to the
Read the detailed Contributing Guide
Copyright (C) 2013 Jason Dobry
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.