You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/libs/langchain/langchain/storage
Chris Papademetrious ee6c922c91
langchain[minor]: enhance `LocalFileStore` to offer `update_atime` parameter that updates access times on read (#20951)
**Description:**
The `LocalFileStore` class can be used to create an on-disk
`CacheBackedEmbeddings` cache. The number of files in these embeddings
caches can grow to be quite large over time (hundreds of thousands) as
embeddings are computed for new versions of content, but the embeddings
for old/deprecated content are not removed.

A *least-recently-used* (LRU) cache policy could be applied to the
`LocalFileStore` directory to delete cache entries that have not been
referenced for some time:

```bash
# delete files that have not been accessed in the last 90 days
find embeddings_cache_dir/ -atime 90 -print0 | xargs -0 rm
```

However, most filesystems in enterprise environments disable access time
modification on read to improve performance. As a result, the access
times of these cache entry files are not updated when their values are
read.

To resolve this, this pull request updates the `LocalFileStore`
constructor to offer an `update_atime` parameter that causes access
times to be updated when a cache entry is read.

For example,

```python
file_store = LocalFileStore(temp_dir, update_atime=True)
```

The default is `False`, which retains the original behavior.

**Testing:**
I updated the LocalFileStore unit tests to test the access time update.
1 month ago
..
__init__.py langchain[patch]: Upgrade storage to treat langchain community as optional (#21105) 1 month ago
_lc_store.py core[patch], langchain[patch]: ByteStore (#14312) 6 months ago
encoder_backed.py langchain[minor]: Add async methods to EncoderBackedStore (#19597) 2 months ago
exceptions.py core[minor],langchain[patch],community[patch]: Move storage interfaces to core (#20750) 1 month ago
file_system.py langchain[minor]: enhance `LocalFileStore` to offer `update_atime` parameter that updates access times on read (#20951) 1 month ago
in_memory.py core[minor],langchain[patch],community[patch]: Move storage interfaces to core (#20750) 1 month ago
redis.py langchain[patch]: Upgrade storage to treat langchain community as optional (#21105) 1 month ago
upstash_redis.py langchain[patch]: Upgrade storage to treat langchain community as optional (#21105) 1 month ago