-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jagdeep91
committed
Apr 25, 2016
1 parent
9803b00
commit 5ac898e
Showing
9 changed files
with
385 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
bower_components | ||
node_modules | ||
web | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,145 @@ | ||
# jsCache | ||
jsCache is a fast and small JavaScript library used for caching at client side. It helps you to increase your application performance. | ||
jsCache is a fast and small JavaScript library used for caching at client side. It helps you to decrease your server load and increase your application performance by caching api | ||
for the time period you want. Not only api you can case every type of data with desired time you want. | ||
It leverage you to organize your caching in different objects with different type of storage and different time for expiry of your caching. Currently it is beta version. | ||
Its Awesome, i promise you will love it just check it out. | ||
|
||
## AngularJs $cacheFactory alternative | ||
|
||
jsCache is an good alternative for AngularJS $cacheFactory with more powerfull functionality. | ||
To know more see [Usage in AngularJS](#usage-in-angularjs) | ||
|
||
## Overview | ||
|
||
* [Installation](#installation) | ||
* [Configuration](#configuration) | ||
* [Getting Started](#getting-started) | ||
* [Usage in AngularJS](#usage-in-angularjs) | ||
* [API](#api-reference) | ||
* [Docs](#docs) | ||
* [Testing](#testing) | ||
|
||
## Installation | ||
|
||
* #### Installing via npm | ||
|
||
```sh | ||
$ npm install js-cache-factory --save | ||
``` | ||
|
||
* #### Installing via bower | ||
|
||
```sh | ||
$ bower install js-cache-factory --save | ||
``` | ||
|
||
* #### Download via cdn | ||
|
||
```sh | ||
Download @ -- pending | ||
``` | ||
|
||
## Configuration | ||
* #### Configure for cache obj | ||
|
||
```javascript | ||
var cacheObjOptions = { | ||
disableCache : false, | ||
maxAge : 24*60*60*1000, // 24 Hours | ||
removeOnExpire : true, | ||
deleteOnExpire : false, | ||
storageMode : "memory", | ||
onExpireCallback : null, // will be available in upcoming version | ||
recycleFrequency : null, // will be available in upcoming version | ||
capacity : null // will be available in upcoming version | ||
}; | ||
``` | ||
|
||
|
||
* #### Configure for key,value you store | ||
|
||
```javascript | ||
var cacheKeyOptions = { | ||
disableCache : false, | ||
maxAge : null, | ||
removeOnExpire : true, | ||
onExpireCallback : null, // will be available in upcoming version | ||
recycleFrequency : null // will be available in upcoming version | ||
}; | ||
``` | ||
|
||
## Getting Started | ||
|
||
* #### Include file in project | ||
|
||
```html | ||
<script src="js-cache.min.js"></script> | ||
``` | ||
* #### Create obj | ||
|
||
```javascript | ||
var cacheObj = jsCache.create("cacheObjName", cacheObjOptions); | ||
``` | ||
* #### Cache anything you want in created obj | ||
|
||
```javascript | ||
cacheObj.put("key", "value", cacheKeyOptions); | ||
``` | ||
|
||
* #### Get saved value anywhere in your project | ||
|
||
```javascript | ||
cacheObj.get("key"); | ||
``` | ||
|
||
That's all you need to do. | ||
You can create multiple objects with different configuration & can store multiple key,values into it. | ||
## Usage in AngularJS | ||
jsCache is very good alternative for $cacheFactory in AngularJS. | ||
* #### cache in $http request | ||
Instead of calling create method | ||
```javascript | ||
var cacheObj = jsCache.create("cacheObjName", cacheObjOptions); | ||
``` | ||
You have to call | ||
```javascript | ||
var httpCacheObj = jsCache.createHttpCache("cacheObjName", cacheObjOptions); | ||
``` | ||
and pass it to | ||
```javascript | ||
$http({ | ||
method: 'GET', | ||
url: "url you provide", | ||
params: obj, | ||
cache : httpCacheObj(cacheKeyOptions) | ||
}) | ||
``` | ||
That's all else angular will take care of saving & retriving data for http calls. | ||
Except $http api cache procedure is same as mentioned in Getting Started guide. | ||
|
||
## Api Reference | ||
|
||
|
||
## Docs | ||
|
||
|
||
## Testing | ||
Run | ||
```sh | ||
$ npm test | ||
``` | ||
|
||
Unit test cases are written to test it properly. You can find test cases inside test.js file. | ||
Although if you find any issue or you need some extra functionality, anything which you find unconmfortable please let us know or raise issue. We would love to hear from you. | ||
|
||
##License | ||
---- | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "jsCache", | ||
"version": "v1.0.0", | ||
"description": "jsCache is a fast and small JavaScript library used for caching at client side. It helps you to decrease your server load and increase your application performance by caching api for the time period you want. Not only api you can case every type of data with desired time you want. It leverage you to organize your caching in different objects with different type of storage and different time for expiry of your caching. Its Awesome, i promise you will love it just check it out", | ||
"main": [ | ||
"build/js-cache-min.js" | ||
], | ||
"authors": [ | ||
"jagdeep91 <[email protected]>" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/funwithjs/jsCache.git" | ||
}, | ||
"keywords": [ | ||
"cache", | ||
"caching", | ||
"store", | ||
"localStorage", | ||
"sessionStorage", | ||
"client side caching", | ||
"javacsript", | ||
"javascript cache", | ||
"performance", | ||
"server speed", | ||
"angular cache factory", | ||
"$cacheFactory", | ||
"cahing options", | ||
"time to live" | ||
], | ||
"dependencies": { | ||
"bootstrap": "~3.3.6", | ||
"angular": "~1.5.0", | ||
"angular-ui-router": "~0.2.15" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var gulp = require('gulp'), | ||
browserSync = require('browser-sync').create(), | ||
bowerFiles = require('main-bower-files'), | ||
inject = require('gulp-inject'), | ||
stylus = require('gulp-stylus'), | ||
es = require('event-stream'), | ||
livereload = require('gulp-livereload'); | ||
|
||
var concat = require('gulp-concat'); | ||
var uglify = require('gulp-uglify'); | ||
var rename = require('gulp-rename'); | ||
|
||
|
||
gulp.task('inject', function() { | ||
return gulp.src('./web/index.html') | ||
.pipe(inject(gulp.src(bowerFiles(), {read: false}), {name: 'bower'})) | ||
.pipe(inject(gulp.src([ | ||
'web/app/app.js', | ||
'web/app/routes/routes.js', | ||
'web/app/modules/**/*.js', | ||
'build/*.js' | ||
],{read: false}))) | ||
.pipe(gulp.dest('./web')); | ||
}); | ||
|
||
gulp.task('watch', function() { | ||
livereload.listen(); | ||
//gulp.watch("./web/**/*.js", ['build']); | ||
gulp.watch("./web/**/*.html", browserSync.reload); | ||
}); | ||
|
||
gulp.task("build", function () { | ||
gulp.src("./web/lib/js-cache/js-cache.js") | ||
.pipe(uglify()) | ||
.pipe(rename("js-cache-min.js")) | ||
.pipe(gulp.dest('./build/')); | ||
}); | ||
|
||
// Static server | ||
gulp.task('serve', ['build', 'inject', 'watch'] , function() { | ||
browserSync.init({ | ||
server: { | ||
baseDir: "./web", | ||
routes: { | ||
"/bower_components": "bower_components", | ||
"/static": "static", | ||
"/web": "web", | ||
"/build": "build" | ||
} | ||
}, | ||
port : 3003, | ||
ghostMode: false | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Karma configuration | ||
// Generated on Mon Jul 20 2015 12:33:04 GMT+0530 (India Standard Time) | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '', | ||
|
||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['jasmine'], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'web/lib/**/*.js', | ||
'test/**/*.js' | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress'], | ||
|
||
|
||
// web server port | ||
port: 3003, | ||
|
||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
|
||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "jsCache", | ||
"version": "v1.0.0", | ||
"description": "jsCache is a fast and small JavaScript library used for caching at client side. It helps you to decrease your server load and increase your application performance by caching api for the time period you want. Not only api you can case every type of data with desired time you want. It leverage you to organize your caching in different objects with different type of storage and different time for expiry of your caching. Its Awesome, i promise you will love it just check it out", | ||
"main": [ | ||
"build/js-cache-min.js" | ||
], | ||
"scripts": { | ||
"test": "karma start", | ||
"start": "gulp serve" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/funwithjs/jsCache.git" | ||
}, | ||
"keywords": [ | ||
"cache", | ||
"caching", | ||
"store", | ||
"localStorage", | ||
"sessionStorage", | ||
"client side caching", | ||
"javacsript", | ||
"javascript cache", | ||
"performance", | ||
"server speed", | ||
"angular cache factory", | ||
"$cacheFactory", | ||
"cahing options", | ||
"time to live" | ||
], | ||
"author": "Jagdeep Singh", | ||
"license": "MIT", | ||
"dependencies": { | ||
"browser-sync": "^2.7.13", | ||
"event-stream": "^3.3.1", | ||
"gulp": "^3.9.0", | ||
"gulp-concat": "^2.6.0", | ||
"gulp-inject": "^1.3.1", | ||
"gulp-livereload": "^3.8.0", | ||
"gulp-load-plugins": "^0.10.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-stylus": "^2.0.5", | ||
"gulp-uglify": "^1.5.3", | ||
"gulp-util": "^3.0.6", | ||
"http": "0.0.0", | ||
"jasmine-core": "^2.3.4", | ||
"karma": "^0.13.3", | ||
"karma-cli": "^0.1.0", | ||
"karma-jasmine": "^0.3.6", | ||
"lodash": "^3.10.0", | ||
"main-bower-files": "^2.9.0", | ||
"path": "^0.11.14", | ||
"st": "^0.5.4", | ||
"wiredep": "^2.2.2" | ||
} | ||
} |
Oops, something went wrong.