Torus.Embeddings.NebulexCache (Torus v0.7.0)

View Source

Caching layer for the embedding module.

A wrapper around Nebulex cache. It allows you to cache the embedding calls in memory, so you save the resources/cost of calling the embedding module multiple times for the same input.

To use it:

  • Add the following to your config.exs:

    config :torus, embedding_module: Torus.Embeddings.NebulexCache
    config :torus, Torus.Embeddings.NebulexCache,
      embedding_module: Torus.Embeddings.PostgresML,
      adapter: Nebulex.Adapters.Local,
      # Other adapter-specific options
      allocated_memory: 1_000_000_000 # 1GB
    
    # Embedding module specific options
    config :torus, Torus.Embeddings.PostgresML, repo: TorusExample.Repo
  • Add nebulex, nebulex_local (for the default local adapter), and decorator to your mix.exs dependencies:

    def deps do
    [
      {:nebulex, ">= 3.0.0"},
      {:nebulex_local, ">= 3.0.0"},
      {:decorator, ">= 0.0.0"}
    ]
    end
  • Add Torus.Embeddings.NebulexCache to your supervision tree:

    def start(_type, _args) do
      children = [
        Torus.Embeddings.NebulexCache
      ]
    
      opts = [strategy: :one_for_one, name: YourApp.Supervisor]
      Supervisor.start_link(children, opts)
    end

See the Nebulex documentation for more information on how to configure the cache.

And you're good to go now. As you can see, we can create a chain of embedding modules to compose the embedding process of our choice. Each of them should implement the Torus.Embedding behaviour, and we're good to go!

Summary

Functions

Callback implementation for Nebulex.Cache.delete/2.

Callback implementation for Nebulex.Cache.delete!/2.

Callback implementation for Nebulex.Cache.fetch/2.

Callback implementation for Nebulex.Cache.fetch!/2.

A convenience function for retrieving the current generations.

A convenience function for creating new generations.

A convenience function for retrieving the newer generation.

Callback implementation for Nebulex.Cache.put/3.

Callback implementation for Nebulex.Cache.put!/3.

A convenience function for reset the GC interval.

Callback implementation for Nebulex.Cache.take/2.

Callback implementation for Nebulex.Cache.take!/2.

Callback implementation for Nebulex.Cache.touch/2.

Callback implementation for Nebulex.Cache.touch!/2.

Callback implementation for Nebulex.Cache.ttl/2.

Callback implementation for Nebulex.Cache.ttl/3.

Callback implementation for Nebulex.Cache.ttl!/2.

Functions

count_all(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.count_all/2.

count_all(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.count_all/3.

count_all!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.count_all!/2.

count_all!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.count_all!/3.

decr(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.decr/3.

decr(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.decr/4.

decr!(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.decr!/3.

decr!(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.decr!/4.

delete(key, opts \\ [])

Callback implementation for Nebulex.Cache.delete/2.

delete(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.delete/3.

delete!(key, opts \\ [])

Callback implementation for Nebulex.Cache.delete!/2.

delete!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.delete!/3.

delete_all(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.delete_all/2.

delete_all(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.delete_all/3.

delete_all!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.delete_all!/2.

delete_all!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.delete_all!/3.

expire(key, ttl, opts \\ [])

Callback implementation for Nebulex.Cache.expire/3.

expire(dynamic_cache, key, ttl, opts)

Callback implementation for Nebulex.Cache.expire/4.

expire!(key, ttl, opts \\ [])

Callback implementation for Nebulex.Cache.expire!/3.

expire!(dynamic_cache, key, ttl, opts)

Callback implementation for Nebulex.Cache.expire!/4.

fetch(key, opts \\ [])

Callback implementation for Nebulex.Cache.fetch/2.

fetch(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.fetch/3.

fetch!(key, opts \\ [])

Callback implementation for Nebulex.Cache.fetch!/2.

fetch!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.fetch!/3.

fetch_or_store(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.fetch_or_store/3.

fetch_or_store(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.fetch_or_store/4.

fetch_or_store!(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.fetch_or_store!/3.

fetch_or_store!(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.fetch_or_store!/4.

generations()

A convenience function for retrieving the current generations.

get(key, default \\ nil, opts \\ [])

Callback implementation for Nebulex.Cache.get/3.

get(dynamic_cache, key, default, opts)

Callback implementation for Nebulex.Cache.get/4.

get!(key, default \\ nil, opts \\ [])

Callback implementation for Nebulex.Cache.get!/3.

get!(dynamic_cache, key, default, opts)

Callback implementation for Nebulex.Cache.get!/4.

get_all(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.get_all/2.

get_all(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.get_all/3.

get_all!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.get_all!/2.

get_all!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.get_all!/3.

get_and_update(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_and_update/3.

get_and_update(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_and_update/4.

get_and_update!(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_and_update!/3.

get_and_update!(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_and_update!/4.

get_or_store(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_or_store/3.

get_or_store(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_or_store/4.

get_or_store!(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_or_store!/3.

get_or_store!(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_or_store!/4.

has_key?(key, opts \\ [])

Callback implementation for Nebulex.Cache.has_key?/2.

has_key?(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.has_key?/3.

in_transaction?(opts \\ [])

Callback implementation for Nebulex.Cache.in_transaction?/1.

in_transaction?(dynamic_cache, opts)

Callback implementation for Nebulex.Cache.in_transaction?/2.

incr(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.incr/3.

incr(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.incr/4.

incr!(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.incr!/3.

incr!(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.incr!/4.

info(spec \\ :all, opts \\ [])

Callback implementation for Nebulex.Cache.info/2.

info(dynamic_cache, spec, opts)

Callback implementation for Nebulex.Cache.info/3.

info!(spec \\ :all, opts \\ [])

Callback implementation for Nebulex.Cache.info!/2.

info!(dynamic_cache, spec, opts)

Callback implementation for Nebulex.Cache.info!/3.

new_generation(opts \\ [])

A convenience function for creating new generations.

newer_generation()

A convenience function for retrieving the newer generation.

put(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put/3.

put(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put/4.

put!(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put!/3.

put!(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put!/4.

put_all(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_all/2.

put_all(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_all/3.

put_all!(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_all!/2.

put_all!(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_all!/3.

put_new(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put_new/3.

put_new(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put_new/4.

put_new!(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put_new!/3.

put_new!(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put_new!/4.

put_new_all(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_new_all/2.

put_new_all(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_new_all/3.

put_new_all!(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_new_all!/2.

put_new_all!(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_new_all!/3.

register_event_listener(listener, opts \\ [])

Callback implementation for Nebulex.Cache.register_event_listener/2.

register_event_listener(dynamic_cache, listener, opts)

Callback implementation for Nebulex.Cache.register_event_listener/3.

register_event_listener!(listener, opts \\ [])

Callback implementation for Nebulex.Cache.register_event_listener!/2.

register_event_listener!(dynamic_cache, listener, opts)

Callback implementation for Nebulex.Cache.register_event_listener!/3.

replace(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.replace/3.

replace(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.replace/4.

replace!(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.replace!/3.

replace!(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.replace!/4.

reset_gc_interval()

A convenience function for reset the GC interval.

stream(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.stream/2.

stream(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.stream/3.

stream!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.stream!/2.

stream!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.stream!/3.

take(key, opts \\ [])

Callback implementation for Nebulex.Cache.take/2.

take(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.take/3.

take!(key, opts \\ [])

Callback implementation for Nebulex.Cache.take!/2.

take!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.take!/3.

touch(key, opts \\ [])

Callback implementation for Nebulex.Cache.touch/2.

touch(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.touch/3.

touch!(key, opts \\ [])

Callback implementation for Nebulex.Cache.touch!/2.

touch!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.touch!/3.

transaction(fun, opts \\ [])

Callback implementation for Nebulex.Cache.transaction/2.

transaction(dynamic_cache, fun, opts)

Callback implementation for Nebulex.Cache.transaction/3.

ttl(key, opts \\ [])

Callback implementation for Nebulex.Cache.ttl/2.

ttl(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.ttl/3.

ttl!(key, opts \\ [])

Callback implementation for Nebulex.Cache.ttl!/2.

ttl!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.ttl!/3.

unregister_event_listener(id, opts \\ [])

Callback implementation for Nebulex.Cache.unregister_event_listener/2.

unregister_event_listener(dynamic_cache, id, opts)

Callback implementation for Nebulex.Cache.unregister_event_listener/3.

unregister_event_listener!(id, opts \\ [])

Callback implementation for Nebulex.Cache.unregister_event_listener!/2.

unregister_event_listener!(dynamic_cache, id, opts)

Callback implementation for Nebulex.Cache.unregister_event_listener!/3.

update(key, initial, fun, opts \\ [])

Callback implementation for Nebulex.Cache.update/4.

update(dynamic_cache, key, initial, fun, opts)

Callback implementation for Nebulex.Cache.update/5.

update!(key, initial, fun, opts \\ [])

Callback implementation for Nebulex.Cache.update!/4.

update!(dynamic_cache, key, initial, fun, opts)

Callback implementation for Nebulex.Cache.update!/5.