Sha256: 2003457c059a042e276e106a7c185782e06498c6f60f12630a620164c4cd40be

Contents?: true

Size: 907 Bytes

Versions: 17

Compression:

Stored size: 907 Bytes

Contents

class Turbolinks.SnapshotCache
  constructor: (@size) ->
    @keys = []
    @snapshots = {}

  has: (location) ->
    key = keyForLocation(location)
    key of @snapshots

  get: (location) ->
    return unless @has(location)
    snapshot = @read(location)
    @touch(location)
    snapshot

  put: (location, snapshot) ->
    @write(location, snapshot)
    @touch(location)
    snapshot

  # Private

  read: (location) ->
    key = keyForLocation(location)
    @snapshots[key]

  write: (location, snapshot) ->
    key = keyForLocation(location)
    @snapshots[key] = snapshot

  touch: (location) ->
    key = keyForLocation(location)
    index = @keys.indexOf(key)
    @keys.splice(index, 1) if index > -1
    @keys.unshift(key)
    @trim()

  trim: ->
    for key in @keys.splice(@size)
      delete @snapshots[key]

  keyForLocation = (location) ->
    Turbolinks.Location.wrap(location).toCacheKey()

Version data entries

17 entries across 16 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ruby2js-4.0.4 lib/tasks/testrails/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ruby2js-4.0.3 lib/tasks/testrails/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
jester-data-8.0.0 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ezii-os-5.2.1 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ezii-os-2.0.1 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ezii-os-1.1.0 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ezii-os-1.0.0 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ezii-os-0.0.0.1.0 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
ezii-os-0.0.0.0.1 node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
rails_auth-1.0.6 test/dummy/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
rails_auth-1.0.5 test/dummy/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
rails_auth-1.0.4 test/dummy/node_modules/turbolinks/src/turbolinks/snapshot_cache.coffee
jekyll-theme-chalk-0.1.1 _assets/yarn/turbolinks/src/turbolinks/snapshot_cache.coffee
jekyll-chalk-0.1.1 assets/bower/turbolinks5/src/turbolinks/snapshot_cache.coffee