Module: Kotoshu::Cache

Defined in:
lib/kotoshu/cache.rb,
lib/kotoshu/cache/cache.rb,
lib/kotoshu/cache/base_cache.rb,
lib/kotoshu/cache/model_cache.rb,
lib/kotoshu/cache/lookup_cache.rb,
lib/kotoshu/cache/language_cache.rb,
lib/kotoshu/cache/frequency_cache.rb,
lib/kotoshu/cache/suggestion_cache.rb

Overview

Cache module for Kotoshu

This module provides access to various cache implementations for dictionaries, models, and other resources.

Examples:

Using the language cache

cache = Kotoshu::Cache::LanguageCache.new
dict = cache.get_spelling('en')
# => { dic_path: "~/.cache/kotoshu/languages/en/spelling/index.dic",
#      aff_path: "~/.cache/kotoshu/languages/en/spelling/index.aff",
#      metadata: { ... } }

Defined Under Namespace

Modules: Cache Classes: BaseCache, FrequencyCache, LanguageCache, LookupCache, ModelCache, SuggestionCache

Class Method Summary collapse

Class Method Details

.language_cache(cache_path: nil, url_base: nil) ⇒ LanguageCache

Create a new language cache instance

Parameters:

  • cache_path (String) (defaults to: nil)

    optional custom cache directory

  • url_base (String) (defaults to: nil)

    optional custom GitHub URL

Returns:



27
28
29
# File 'lib/kotoshu/cache.rb', line 27

def language_cache(cache_path: nil, url_base: nil)
  LanguageCache.new(cache_path: cache_path, url_base: url_base)
end

.model_cache(cache_path: nil) ⇒ ModelCache

Create a new model cache instance

Parameters:

  • cache_path (String) (defaults to: nil)

    optional custom cache directory

Returns:



35
36
37
# File 'lib/kotoshu/cache.rb', line 35

def model_cache(cache_path: nil)
  ModelCache.new(cache_path: cache_path)
end