Skip to main content

LRU Cache

Package for tracking store in-data memory using replacement cache algorithm / LRU cache. The Priority of storing or removing the data based on Min-Max heap algorithm or basic priority queue instead using OrderedDict module that provided by Python.

Purpose

The purpose of using this package itself is at least to be able to dynamically tracking. inserting, and removing least frequently used in-data memory or in an element. Another purposes, with the use of python decorator or the method looks like, it's also possible to figure it out whether the data in the cache is full or not (it's called LRU eviction), since LRU cache is using O(1) complexity, it's also possible to efficiently accessing the store in-data memory based on most frequently used method.

Usage

The package is still being under developed and haven't packaged and published into PyPi index. However, there is a little explanation regarding the use of this LRU cache. The basic usage is pretty common by using a List and accessing that List like example :

from lru import LRUCache

# set the max of cache capacity
foo = LRUCache(3)

# set the items
foo.set(1, "value")
foo.set(2, "cooke")
foo.set(3, "water")
foo.set(4, "gets")
foo.set(5, "sets")

# get the items
foo.get(3)
foo.get(4)
foo.get(5)

print(foo.get_dict())
print(foo.get_lru_element())

The get_dict() method returns a dictionary of an object with a maximum capacity of 3 (which was initialized at first), whereas the objects that taken from the dictionary based on objects that are recently used (this is indicated by the get() method), while the get_lru_element() method is used for retrieve an object based on the duration when accessing onto the dictionary.

For further example, hopefully this package can be backported with Python web frameworks such as Django or Flask which can be implemented and supported in the JSON field area, since the return of this LRUCache value is in the form of dictionary which is very common in JSON type.

Contributions

Since this package is still being under developed, any contributions are much welcomed and you can read on contribution page.

License

This package is licensed under the MIT License.

Metadata

Release files for lruheap 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lruheap 0.0.1
File Size Uploaded
lruheap-0.0.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lruheap 0.0.1
File Interpreter ABI Platform
lruheap-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / lruheap-0.0.1.tar.gz

Download URL lruheap-0.0.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bee86fdfa095957d1adf744c467e395c06efa3090b90982ced81bb401fcdbcb2
BLAKE2b-256 checksum
How to use checksums
b5399c978e9bb8f7f4c3478923a019816bc28c5cb54438ddd26b8b5f5119b235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release files / lruheap-0.0.1-py3-none-any.whl

Download URL lruheap-0.0.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d4bc4fb7159441ae154a9292f6ee8246f42975122780c4da0578219e055a15a
BLAKE2b-256 checksum
How to use checksums
ebb7434f770fe3d0c8c0bcfc11848fd57c8510403b385cbd07ca4015921125c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release history Release notifications | RSS feed

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page