Class: Proj::GridCache
- Inherits:
-
Object
- Object
- Proj::GridCache
- Defined in:
- lib/proj/grid_cache.rb
Overview
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
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#clear ⇒ Object
Clears the cache.
-
#enabled=(value) ⇒ Object
Enables or disables the grid cache.
-
#initialize(context) ⇒ GridCache
constructor
A new instance of GridCache.
-
#max_size=(value) ⇒ Object
Sets the cache size.
-
#path=(value) ⇒ Object
Set the path and file of the local cache file which is sqlite database.
-
#ttl=(value) ⇒ Object
Specifies the time-to-live delay for re-checking if the cached properties of files are still up-to-date.
Constructor Details
#initialize(context) ⇒ GridCache
Returns a new instance of GridCache.
13 14 15 |
# File 'lib/proj/grid_cache.rb', line 13 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'lib/proj/grid_cache.rb', line 11 def context @context end |
Instance Method Details
#clear ⇒ Object
Clears the cache
60 61 62 |
# File 'lib/proj/grid_cache.rb', line 60 def clear Api.proj_grid_cache_clear(self.context) end |
#enabled=(value) ⇒ Object
Enables or disables the grid cache
22 23 24 |
# 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) ⇒ Object
Sets the cache size
42 43 44 45 |
# 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) ⇒ Object
Set the path and file of the local cache file which is sqlite database. By default it is stored in the user writable directory.
32 33 34 35 |
# 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) ⇒ Object
Specifies the time-to-live delay for re-checking if the cached properties of files are still up-to-date.
52 53 54 55 |
# File 'lib/proj/grid_cache.rb', line 52 def ttl=(value) Api.proj_grid_cache_set_ttl(self.context, value) value end |