Skip to content

Commit 760b042

Browse files
fholecpsss
authored andcommitted
Persistent cache implementation
New Cache class handling persistence and expiration Various class adjustments to handle object expiration Cache level detection from the user config file Added detailed documentation for all cache features Signed-off-by: Petr Šplíchal <psplicha@redhat.com>
1 parent 93d5917 commit 760b042

File tree

2 files changed

+275
-75
lines changed

2 files changed

+275
-75
lines changed

source/__init__.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,61 @@
8282
multicall_end() is called, all queries are sent to server in a batch.
8383
8484
85+
Caching support
86+
~~~~~~~~~~~~~~~
87+
88+
In order to save calls to server and time, caching support has been
89+
implemented. Every class that handles objects has its own cache and it
90+
is used to save already initialized (fetched) objects from server.
91+
Immutable classes are automatically fetched from server after
92+
initialization, the rest will be fetched from server upon request.
93+
94+
Methods that manipulate caching levels:
95+
96+
get_cache_level()
97+
set_cache_level()
98+
99+
Currently, there are four types (levels) of caching:
100+
101+
CACHE_NONE ......... no caching at all, changes applied immediately
102+
CACHE_CHANGES ...... cache only local updates of instance attributes
103+
CACHE_OBJECTS ...... caching of objects for further use (default)
104+
CACHE_PERSISTENT ... persistent caching of objects into a local file
105+
106+
By default CACHE_OBJECTS is used. That means any changes to objects are
107+
pushed to the server only when explicitly requested with the update()
108+
method. Also, any object already loaded from the server is kept in
109+
memory cache so that future references to that object are faster.
110+
111+
Persistent cache (local proxy) further speeds up module performance. It
112+
allows class caches to be stored in a file, load caches from a file, and
113+
clear caches. This performance improvement is very helpful mainly for
114+
immutable classes (for example User), where all users can be imported in
115+
the beginning of a script and a lot of connections can be saved. To
116+
activate this feature specify cache level and file name in the config:
117+
118+
[cache]
119+
level = 3
120+
file = /home/user/.cache/nitrate
121+
122+
Cache expiration is a way how to prevent using probably obsoleted object
123+
(for example caserun). Every class has its own default expiration time,
124+
which can be adjusted in the config file (use lower case class names):
125+
126+
[expiration]
127+
caserun = 60
128+
testcase = 600
129+
130+
Expiration time is given in seconds. In addition, there are two special
131+
values which can be used:
132+
133+
NEVER_CACHE .... no caching of certain class objects
134+
NEVER_EXPIRE ... cached objects never expire
135+
136+
Default expiration is set to 30 days for immutable classes and to 1 hour
137+
for the rest.
138+
139+
85140
Search support
86141
~~~~~~~~~~~~~~
87142
@@ -169,11 +224,12 @@
169224
TestPlan PlanType PlanStatus
170225
TestRun RunStatus
171226
TestCase CaseStatus
172-
CaseRun Status
227+
CaseRun Status Cache
173228
174229
ascii color listed pretty
175230
log info setLogLevel
176-
setCacheLevel CACHE_NONE CACHE_CHANGES CACHE_OBJECTS CACHE_ALL
231+
setCacheLevel CACHE_NONE CACHE_CHANGES CACHE_OBJECTS CACHE_PERSISTENT
232+
NEVER_EXPIRE NEVER_CACHE
177233
setColorMode COLOR_ON COLOR_OFF COLOR_AUTO
178234
set_log_level set_cache_level set_color_mode
179235
get_log_level get_cache_level get_color_mode

0 commit comments

Comments
 (0)