Limit cache location to be in memory or in a default location.
Review Request #6648 — Created Nov. 26, 2014 and submitted
The HTTP cache for the API now takes a parameter that determines if it
is created in memory (create_db_in_memory
). This parameter replaces
thedb_path
parameter, which previously accepted the special value
':memory:'
to create the SQLite database in memory. The new
parameter is more straightforward because caches will only ever be
required to be created at the default location (for normal operation)
or in memory (for unit testing).The default API cache path is stored on the
APICache
class as the
CACHE_PATH
constant, which can be used without instantiating the
class. Becuase the HTTP cache for the API is only ever stored in one
location on disk, it can be cleared (i.e., unlinked) without
instantiating the class to determine where it is located on disk. This
is important in the case where the cache exists but has become corrupt
and cannot be loaded (and so instantiation of the APICache class will
fail).
Unit tests pass.
-
Tool: PEP8 Style Checker Processed Files: rbtools/api/tests.py rbtools/utils/filesystem.py rbtools/api/cache.py Tool: Pyflakes Processed Files: rbtools/api/tests.py rbtools/utils/filesystem.py rbtools/api/cache.py
- Commit:
-
aa7ca29db4d352e5e371a711c264c266e79ea0d3d3a15bc104aa9761ea9bb8ffb97485e7717392c7
- Diff:
-
Revision 3 (+57 -57)
-
Tool: Pyflakes Processed Files: rbtools/api/tests.py rbtools/api/cache.py Tool: PEP8 Style Checker Processed Files: rbtools/api/tests.py rbtools/api/cache.py
- Summary:
-
Allow cache to be cleared without instantiating it.Allow cache to be cleared without instantiating it. The cache can now only be created at the default location or in memory.
- Description:
-
The HTTP cache for the API now takes a parameter that determines if it
~ is created in memory ( create_db_in_memory
) instead of specifying the~ special location ':memory:'
to thedb_path
parameter. The default~ path is now stored on the class as the CACHE_PATH
field. This allows~ the cache path to be determined without it being instantiated. ~ is created in memory ( create_db_in_memory
). This parameter replaces~ the db_path
parameter, which previously accepted the special value~ ':memory:'
to create the SQLite database in memory. The new~ parameter is more straightforward because caches will only ever be + required to be created at the default location (for normal operation) + or in memory (for unit testing). + + The default API cache path is stored on the
APICache
class as the+ CACHE_PATH
constant, which can be used without instantiating the+ class. This allows the cache to be cleared if it exists and has + become corrupt and cannot be loaded.
- Summary:
-
Allow cache to be cleared without instantiating it. The cache can now only be created at the default location or in memory.Limit cache location to be in memory or in a default location.
- Description:
-
The HTTP cache for the API now takes a parameter that determines if it
is created in memory ( create_db_in_memory
). This parameter replacesthe db_path
parameter, which previously accepted the special value':memory:'
to create the SQLite database in memory. The newparameter is more straightforward because caches will only ever be required to be created at the default location (for normal operation) or in memory (for unit testing). The default API cache path is stored on the
APICache
class as theCACHE_PATH
constant, which can be used without instantiating the~ class. This allows the cache to be cleared if it exists and has ~ become corrupt and cannot be loaded. ~ class. Becuase the HTTP cache for the API is only ever stored in one ~ location on disk, it can be cleared (i.e., unlinked) without + instantiating the class to determine where it is located on disk. This + is important in the case where the cache exists but has become corrupt + and cannot be loaded (and so instantiation of the APICache class will + fail).