June 2019
Beginner to intermediate
770 pages
19h 24m
English
We added an index to each Blog that locates Posts that belong to the Blog. We can also add a top-level cache to the shelf that is slightly faster to locate all Blog instances. The essential design is similar to what's been shown in the previous section. For each blog to be added or deleted, we must update a cache of valid keys. We must also update the iterators to properly use the index. Here's another class design to mediate the access to our objects:
class Access3(Access2): def new(self, path: Path) -> None: super().new(path) self.database["_Index:Blog"] = list() def create_blog(self, blog: Blog) -> Blog: super().create_blog(blog) self.database["_Index:Blog"] += [blog._id] return blog def blog_iter(self) -> Iterator[Blog]: ...
Read now
Unlock full access