turbolinks
Version:
Turbolinks makes navigating your web application faster
44 lines (34 loc) • 907 B
text/coffeescript
class Turbolinks.SnapshotCache
constructor: ( ) ->
= []
= {}
has: (location) ->
key = keyForLocation(location)
key of
get: (location) ->
return unless
snapshot =
snapshot
put: (location, snapshot) ->
snapshot
# Private
read: (location) ->
key = keyForLocation(location)
[key]
write: (location, snapshot) ->
key = keyForLocation(location)
[key] = snapshot
touch: (location) ->
key = keyForLocation(location)
index = .indexOf(key)
.splice(index, 1) if index > -1
.unshift(key)
trim: ->
for key in .splice( )
delete [key]
keyForLocation = (location) ->
Turbolinks.Location.wrap(location).toCacheKey()