0001-utils-be-more-efficient-at-caching-warehouses-27412.patch
bijoe/utils.py | ||
---|---|---|
26 | 26 |
from .schemas import Warehouse |
27 | 27 | |
28 | 28 | |
29 |
_cached_warehouses = None |
|
29 | 30 |
def get_warehouses(): |
31 |
global _cached_warehouses |
|
30 | 32 |
if cache.get('warehouses_cache'): |
31 |
return cache.get('warehouses_cache')
|
|
33 |
return _cached_warehouses
|
|
32 | 34 |
warehouses = [] |
33 | 35 |
for pattern in settings.BIJOE_SCHEMAS: |
34 | 36 |
for path in glob.glob(pattern): |
... | ... | |
37 | 39 |
pattern = os.path.join(connection.tenant.get_directory(), 'schemas', '*.model') |
38 | 40 |
for path in glob.glob(pattern): |
39 | 41 |
warehouses.append(Warehouse.from_json(json.load(open(path)))) |
40 |
cache.set('warehouses_cache', warehouses, 30) |
|
42 |
_cached_warehouses = warehouses |
|
43 |
cache.set('warehouses_cache', True, 30) |
|
41 | 44 |
return warehouses |
42 | 45 | |
43 | 46 | |
44 |
- |