mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 19:24:59 +00:00
![]() # Context: USER: persist the `IDENT_CACHE` to .aider.ident.cache whenever it is updated ASSISTANT: To persist the `IDENT_CACHE` to `.aider.ident.cache` whenever it is updated, we need to modify the `get_name_identifiers` method in the `RepoMap` class. Here are the changes: ```python aider/repomap.py <<<<<<< ORIGINAL def get_name_identifiers(self, fname, uniq=True): file_mtime = os.path.getmtime(fname) cache_key = fname if cache_key in self.IDENT_CACHE and self.IDENT_CACHE[cache_key]["mtime"] == file_mtime: idents = self.IDENT_CACHE[cache_key]["data"] else: idents = self.get_name_identifiers_uncached(fname) self.IDENT_CACHE[cache_key] = {"mtime": file_mtime, "data": idents} ======= import json class RepoMap: # ... IDENT_CACHE_FILE = ".aider.ident.cache" def __init__(self, use_ctags=None, root=None, main_model="gpt-4"): # ... self.load_ident_cache() def load_ident_cache(self): if os.path.exists(self.IDENT_CACHE_FILE): with open(self.IDENT_CACHE_FILE, "r") as f: self.IDENT_CACHE = json.load(f) else: self.IDENT_CACHE = dict() def save_ident_cache(self): with open(self.IDENT_CACHE_FILE, "w") as f: json.dump(self.IDENT_CACHE, f) def get_name_identifiers(self, fname, uniq=True): file_mtime = os.path.getmtime(fname) cache_key = fname if cache_key in self.IDENT_CACHE and self.IDENT_CACHE[cache_key]["mtime"] == file_mtime: idents = self.IDENT_CACHE[cache_key]["data"] else: idents = self.get_name_identifiers_uncached(fname) self.IDENT_CACHE[cache_key] = {"mtime": file_mtime, "data": idents} self.save_ident_cache() >>>>>>> UPDATED ``` This will load the `IDENT_CACHE` from the `.aider.ident.cache` file when the `RepoMap` class is initialized and save the cache to the file whenever it is updated. |
||
---|---|---|
.. | ||
__init__.py | ||
coder.py | ||
commands.py | ||
dump.py | ||
io.py | ||
main.py | ||
prompts.py | ||
repomap.py | ||
utils.py |