Skip to content

Commit

Permalink
add insert_guarantee option
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1100717 committed Nov 18, 2014
1 parent 9093cbb commit d768d8a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/core/proxy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define (require, exports, module) ->
@encrypt = options.encrypt
@name = options.name
@proxy = options.proxy
@insert_guarantee = options.insert_guarantee
@evemit = new Evemit()
@iframe = Utils.createIframe @proxy
Evemit.bind window, "message", (e) ->
Expand All @@ -29,6 +30,7 @@ define (require, exports, module) ->
data.expire = @expire
data.encrypt = @encrypt
data.name = @name
data.insert_guarantee = @insert_guarantee
@evemit.once eve, callback
data = JSON.stringify data
ifrWin = @iframe.contentWindow
Expand Down
2 changes: 2 additions & 0 deletions src/core/proxy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/core/storage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define (require, exports, module) ->
@expire = options.expire
@encrypt = options.encrypt
@token = options.name
@insert_guarantee = options.insert_guarantee
if @expire is "window"
throw new Error("sessionStorage is not supported!") if not Support.sessionstorage()
@storage = sessionStorage
Expand Down Expand Up @@ -42,9 +43,11 @@ define (require, exports, module) ->
@storage.setItem(key, val)
catch e
### TODO
* 需要在LocalDB的构造函数中增加配置参数,来确定是否自动删除最老数据
* 增加过期时间配置项
###
if not @insert_guarantee
callback(e)
return
val = Encrypt.decode(val, @token) if @encrypt
data = Utils.parse val
while cnt > 10
Expand Down
6 changes: 5 additions & 1 deletion src/core/storage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/localdb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ define (require, exports, module) ->
@expire = if options.expire? then options.expire else "window"
@encrypt = if options.encrypt? then options.encrypt else true
@proxy = if options.proxy? then options.proxy else null
@insert_guarantee = if options.guarantee then options.guarantee else false
@engine = new Engine {
expire: @expire
encrypt: @encrypt
name: @name
proxy: @proxy
insert_guarantee: @insert_guarantee
}

# get options
Expand Down
4 changes: 3 additions & 1 deletion src/localdb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d768d8a

Please sign in to comment.