[ditrack commit] r2389 - src/trunk/DITrack/DB
Vlad Skvortsov
vss at 73rus.com
Thu Jan 24 17:46:07 PST 2008
oleg at ditrack.org wrote:
> Author: oleg
> Date: 2007-11-24 09:03:55 -0800 (Sat, 24 Nov 2007)
> New Revision: 2389
>
> Modified:
> src/trunk/DITrack/DB/WC.py
> Log:
> implemented caching of firm issues
>
>
> Modified: src/trunk/DITrack/DB/WC.py
> ===================================================================
> --- src/trunk/DITrack/DB/WC.py 2007-11-24 08:49:28 UTC (rev 2388)
> +++ src/trunk/DITrack/DB/WC.py 2007-11-24 17:03:55 UTC (rev 2389)
> @@ -36,6 +36,7 @@
>
> # DITrack modules
> import DITrack.SVN
> +import DITrack.DB.Cache
> import DITrack.DB.Issue
>
> # Comment file name regular expression.
> @@ -142,6 +143,7 @@
> self.next_num_path = os.path.join(path, "meta", "next-id")
> self.svn = DITrack.SVN.Client(svn_path)
> self.meta = DITrack.DB.Common.open_shelving(path, META_FILE)
> + self.cache = DITrack.DB.Cache.Cache(path)
>
> def _get_next_comment_number(self, path):
> """
> @@ -249,7 +251,8 @@
> for op in changes:
> op.fill_txn(txn)
>
> - # XXX: if failed to commit, revert local changes.
> + # XXX: if failed to commit, revert local changes and don't clean cache.
> + self.cache.clear()
>
Why do we need to clean the cache here? Since we've introduced
autodetection of updated issues, I don't think it's longer needed.
> txn.commit(logmsg)
>
> def issues(self):
> @@ -258,6 +261,9 @@
> working copy.
> """
>
> + if len(self.cache):
> + return self.cache.get()
> +
> issue_re = re.compile("^i(\\d+)$")
>
> lst = []
> @@ -274,6 +280,8 @@
> issue = DITrack.DB.Issue.Issue.load(path)
> res.append((id, issue))
>
> + self.cache.set(res)
> +
> return res
>
> def new_comment(self, issue_num, comment):
> @@ -432,6 +440,8 @@
>
> try:
> us = self.svn.update(self.path)
> + if us:
> + self.cache.clear()
>
Same here I guess. Seems like we can get rid of the clear() method
altogether?
--
Vlad Skvortsov, vss at 73rus.com, http://vss.73rus.com
More information about the Dev
mailing list