Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
a68c6fee
Commit
a68c6fee
authored
Sep 21, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] add a clean_cache() method for the cache obj
parent
227c27c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
db_cache.py
gargantext/util/db_cache.py
+14
-0
No files found.
gargantext/util/db_cache.py
View file @
a68c6fee
...
@@ -46,6 +46,9 @@ class ModelCache(dict):
...
@@ -46,6 +46,9 @@ class ModelCache(dict):
class
Cache
:
class
Cache
:
def
__getattr__
(
self
,
key
):
def
__getattr__
(
self
,
key
):
'''
lazy init of new modelcaches: self.Node, self.User...
'''
try
:
try
:
model
=
getattr
(
models
,
key
)
model
=
getattr
(
models
,
key
)
except
AttributeError
:
except
AttributeError
:
...
@@ -54,4 +57,15 @@ class Cache:
...
@@ -54,4 +57,15 @@ class Cache:
setattr
(
self
,
key
,
modelcache
)
setattr
(
self
,
key
,
modelcache
)
return
modelcache
return
modelcache
def
clean_all
(
self
):
'''
re-init any existing modelcaches
'''
for
modelname
in
self
.
__dict__
:
old_modelcache
=
getattr
(
cache
,
modelname
)
new_modelcache
=
ModelCache
(
old_modelcache
.
_model
)
del
old_modelcache
setattr
(
cache
,
modelname
,
new_modelcache
)
cache
=
Cache
()
cache
=
Cache
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment