Resource cache

Open
#24 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Start by reviewing the resource-loading use case in sublime_lib.syntax and the Sublime Text find_resources API described in the issue. The proposal is still seeking feedback rather than naming an implementation location or tests; done would require an agreed cache design and a resulting pull request.

Written by the indexing model from the issue text.

Description

discussion

Sometimes, a plugin will want to load data from an open-ended number of resources. A motivating example is our own use of sublime-syntax and tmLanguage files in sublime_lib.syntax. Another example is the in-development SublimeTemplate package, which looks for and parses sublime-template files. A more nebulous example might be JS Custom, when I find a graceful way to handle user-provided syntax extensions.

Loading and processing all of these files could be a performance risk. The obvious solution is caching.

An eager approach using listeners might be a bit complicated. A lazier approach would be to check file modification times when a list is requested. This should probably work well enough, unless there are OS-specific issues I'm not aware of.

A cache would be initialized with:

  • A pattern like *.sublime-template, or maybe a list of patterns.
  • (optional) A filtering function operating on resource paths.
  • A transformation, such as a parsing function.

The cache would keep a map from resource paths to:

  • The actual OS file path (which might end at a sublime-package).
  • That path's last modification time.
  • The transformed data.

When the user requests a list of items, the cache would call sublime.find_resources, check the locations and modification times of those files, refresh any that have moved or been modified; then, return the list.

Thoughts? If the general idea seems reasonable, I'll write up a PR.

Dominant language
Python
Stars
56
Forks
4
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SublimeText/sublime_lib

All issues in SublimeText/sublime_lib

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.