useful for unit tests or prototyping. Do not use this cache if you need to actually store the embeddings.store = InMemoryStore()underlying_embeddings = OpenAIEmbeddings()embedder = CacheBackedEmbeddings.from_bytes_store(    underlying_embeddings, store, namespace=underlying_embeddings.model)embeddings = embedder.embed_documents(["hello", "goodbye"])    CPU times: user 10.9 ms, sys: 916 ¬µs, total: 11.8 ms    Wall time: 159 msThe second time we try to embed the embedding time is only 2 ms because the embeddings are looked up in the cache.embeddings_from_cache = embedder.embed_documents(["hello", "goodbye"])    CPU times: user 1.67 ms, sys: 342 ¬µs, total: 2.01 ms    Wall time: 2.01 msembeddings == embeddings_from_cache    TrueFile system‚ÄãThis section covers how to use a file system store.fs = LocalFileStore("./test_cache/")embedder2 = CacheBackedEmbeddings.from_bytes_store(    underlying_embeddings, fs, namespace=underlying_embeddings.model)embeddings = embedder2.embed_documents(["hello", "goodbye"])    CPU times: user 6.89 ms, sys: 4.89 ms, total: 11.8 ms    Wall time: 184 msembeddings = embedder2.embed_documents(["hello", "goodbye"])    CPU times: user 0 ns, sys: 3.24 ms, total: 3.24 ms    Wall time: 2.84 msHere are the embeddings that have been persisted to the directory ./test_cache. Notice that the embedder takes a namespace parameter.list(fs.yield_keys())    ['text-embedding-ada-002e885db5b-c0bd-5fbc-88b1-4d1da6020aa5',     'text-embedding-ada-0026ba52e44-59c9-5cc9-a084-284061b13c80']Upstash Redis Store‚Äãfrom langchain.storage.upstash_redis import UpstashRedisStorefrom upstash_redis import RedisURL = "<UPSTASH_REDIS_REST_URL>"TOKEN = "<UPSTASH_REDIS_REST_TOKEN>"redis_client = Redis(url=URL, token=TOKEN)store = UpstashRedisStore(client=redis_client, ttl=None, namespace="test-ns")underlying_embeddings = OpenAIEmbeddings()embedder = CacheBackedEmbeddings.from_bytes_store(    underlying_embeddings, store, namespace=underlying_embeddings.model)embeddings =
Embeddings can be stored or temporarily cached to avoid needing to recompute them.
Embeddings can be stored or temporarily cached to avoid needing to recompute them. ->: useful for unit tests or prototyping. Do not use this cache if you need to actually store the embeddings.store = InMemoryStore()underlying_embeddings = OpenAIEmbeddings()embedder = CacheBackedEmbeddings.from_bytes_store(    underlying_embeddings, store, namespace=underlying_embeddings.model)embeddings = embedder.embed_documents(["hello", "goodbye"])    CPU times: user 10.9 ms, sys: 916 ¬µs, total: 11.8 ms    Wall time: 159 msThe second time we try to embed the embedding time is only 2 ms because the embeddings are looked up in the cache.embeddings_from_cache = embedder.embed_documents(["hello", "goodbye"])    CPU times: user 1.67 ms, sys: 342 ¬µs, total: 2.01 ms    Wall time: 2.01 msembeddings == embeddings_from_cache    TrueFile system‚ÄãThis section covers how to use a file system store.fs = LocalFileStore("./test_cache/")embedder2 = CacheBackedEmbeddings.from_bytes_store(    underlying_embeddings, fs, namespace=underlying_embeddings.model)embeddings = embedder2.embed_documents(["hello", "goodbye"])    CPU times: user 6.89 ms, sys: 4.89 ms, total: 11.8 ms    Wall time: 184 msembeddings = embedder2.embed_documents(["hello", "goodbye"])    CPU times: user 0 ns, sys: 3.24 ms, total: 3.24 ms    Wall time: 2.84 msHere are the embeddings that have been persisted to the directory ./test_cache. Notice that the embedder takes a namespace parameter.list(fs.yield_keys())    ['text-embedding-ada-002e885db5b-c0bd-5fbc-88b1-4d1da6020aa5',     'text-embedding-ada-0026ba52e44-59c9-5cc9-a084-284061b13c80']Upstash Redis Store‚Äãfrom langchain.storage.upstash_redis import UpstashRedisStorefrom upstash_redis import RedisURL = "<UPSTASH_REDIS_REST_URL>"TOKEN = "<UPSTASH_REDIS_REST_TOKEN>"redis_client = Redis(url=URL, token=TOKEN)store = UpstashRedisStore(client=redis_client, ttl=None, namespace="test-ns")underlying_embeddings = OpenAIEmbeddings()embedder = CacheBackedEmbeddings.from_bytes_store(    underlying_embeddings, store, namespace=underlying_embeddings.model)embeddings =