Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: CacheMap #11

Merged
merged 47 commits into from
Dec 4, 2023
Merged

Feature: CacheMap #11

merged 47 commits into from
Dec 4, 2023

Conversation

deavmi
Copy link
Owner

@deavmi deavmi commented Nov 27, 2023

Purpose ✍️

Add support for a CacheMap and a CacheList.

Todo

  • CacheMap

    • Alive strat.
    • On-access strat.
    • Use delegate
    • Force expiration
  • CacheList

    • Alive strat.
    • On-access strat.
    • Use delegate
  • Unit tests

    • Threaded expiration
    • On-access expiration
    • Explicit key removal
  • Documentation

- Created module
- Added new enum with members `LIVE` and `ON_ACCESS`
- Added entry
- Added initial implementation

CacheMap (unitests)

- Added a unittest
- Added a stub `CacheList` container type
@deavmi deavmi added the enhancement New feature or request label Nov 27, 2023
@deavmi deavmi self-assigned this Nov 27, 2023
@deavmi
Copy link
Owner Author

deavmi commented Nov 27, 2023

If we do a trivial on access we scale badly with O(n) for traversal, so we could configure hitcount or time-based.

Time based feels right, but it would have to be bounded surely by min time, and that is complicated.

Or well, maybe relative to everything else, time "freezes" and unfreezes when we traverse, it's really LRU we care about than the strict time value I guess.

@deavmi
Copy link
Owner Author

deavmi commented Nov 27, 2023

Okay maar ek suip lekker nou 🍺

- Implement the static ifdefs to set
- Use the hitcount method
- Disbale hitcount for now
- Added `ReplacementFunction`
- Implemented `updateKey(K key)`
- Implemented `expirationCheck(K key)`
- Updated `get(K key)` to use the new `K` key-based exipiration check
- The method `updateKey(K key)` now returns the value refreshed
- `get(K key)` now refrehses on unfound key
- Implemented `makeKey(K key)`
- Busy reworking, still broken
- Fixed errors with compilation in `makeKey(K key)`
- Fixed `expirationCheck(K key)` by using `makeKey(K key)` whenever the key does not yet exist
@deavmi
Copy link
Owner Author

deavmi commented Nov 27, 2023

Okay, maar I have on-access working now it seems, for CacheMap

- Fixed unit test
@deavmi
Copy link
Owner Author

deavmi commented Nov 27, 2023

Unit test is gucci ✔️

- Removed `put(K, V)` method
- Removed traversal version `expirationCheck()`
- Force compilation failure when `get()` is called for LIVE strat
- Added proper `~this()` implementation for LIVE strat
- Documented methods
- Updated `get(K)`
- Either a function or delegate may now be used
@deavmi
Copy link
Owner Author

deavmi commented Nov 28, 2023

Added delegate support ✔️

- Removed nop
- Documented `checkerFunc()`
- Documented `doLiveCheck()` and `~this()`
- Documented module
- Added import
@deavmi
Copy link
Owner Author

deavmi commented Dec 1, 2023

Documentation ✔️

- Implemented `removeKey(K key)`
- Documented `removeKey(K)`
- Explcitiyl set time
- Added a test ofkey removal (explicit)
- Destroy map
- Added missing documentation
@deavmi
Copy link
Owner Author

deavmi commented Dec 2, 2023

Added explicit key removal ✔️

@deavmi deavmi changed the title Feature: CacheMap, CacheList Feature: CacheMap Dec 4, 2023
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Explicit key removal works ✔️

- Removed old code
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Threaded expiration ✔️

- Cleaned up
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

No tests yet for on-access expiration

@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Adding sweep interval customization...

@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Adding on-acces unittest

- Fixed the constructor which takes in a `ReplacementFunction` to pass in the default arguments as well
- The `checkerFunc` now uses the `sweepInterval`
- Added support for a `sweepInterval` which the checker runs at now (seperate to the `expirationTime`)

CacheMap (unittest)

- Documented more unittests
- Added a unit test for on-access stratergy testing
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Adding sweep interval customization...

Done ✔️

@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Adding sweep interval customization...

Done ✔️

Done ✔️

- Cleaned up imports
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Okay, this is all done - will be merging now

- Made `ReplacementDelegate` and `ReplacementFunction` public and added documentation
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Added more docs

@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Done, merging...

@deavmi deavmi merged commit bdcbb1b into master Dec 4, 2023
2 of 4 checks passed
@deavmi
Copy link
Owner Author

deavmi commented Dec 4, 2023

Merged ✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant