class Proj::GridCache

To avoid repeated network access, it is possible to enable a local cache of grids. Grid data is stored in a SQLite3 database, cache.db, that is by default stored stored in the PROJ user writable directory.

The local cache is enabled by default with a size of 300MB. Cache settings can be overridden by this class, env variables or the proj.ini file

@see proj.org/usage/network.html#caching

Attributes

context[R]

Public Class Methods

new(context) click to toggle source
# File lib/proj/grid_cache.rb, line 13
def initialize(context)
  @context = context
end

Public Instance Methods

clear() click to toggle source

Clears the cache

@see proj.org/development/reference/functions.html#c.proj_grid_cache_clear

# File lib/proj/grid_cache.rb, line 60
def clear
  Api.proj_grid_cache_clear(self.context)
end
enabled=(value) click to toggle source

Enables or disables the grid cache

@param value [Boolean]

@see proj.org/development/reference/functions.html#c.proj_grid_cache_set_enable

# File lib/proj/grid_cache.rb, line 22
def enabled=(value)
  Api.proj_grid_cache_set_enable(self.context, value ? 1 : 0)
end
max_size=(value) click to toggle source

Sets the cache size

@param value [Integer] Maximum size in Megabytes (1024*1024 bytes), or negative value to set unlimited size.

@see proj.org/development/reference/functions.html#c.proj_grid_cache_set_max_size

# File lib/proj/grid_cache.rb, line 42
def max_size=(value)
  Api.proj_grid_cache_set_max_size(self.context, value)
  value
end
path=(value) click to toggle source

Set the path and file of the local cache file which is sqlite database. By default it is stored in the user writable directory.

@param value [String] - Full path to the cache. If set to nil then caching will be disabled.

@see proj.org/development/reference/functions.html#c.proj_grid_cache_set_filename

# File lib/proj/grid_cache.rb, line 32
def path=(value)
  Api.proj_grid_cache_set_filename(self.context, value.encode('UTF-8'))
  value
end
ttl=(value) click to toggle source

Specifies the time-to-live delay for re-checking if the cached properties of files are still up-to-date.

@param value [Integer] Delay in seconds. Use negative value for no expiration.

@see proj.org/development/reference/functions.html#c.proj_grid_cache_set_ttl

# File lib/proj/grid_cache.rb, line 52
def ttl=(value)
  Api.proj_grid_cache_set_ttl(self.context, value)
  value
end