Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

How to remove specific Keys from the Cache without clearing all of them #193

Closed
JATQK opened this issue Jul 7, 2021 · 4 comments
Closed

Comments

@JATQK
Copy link

JATQK commented Jul 7, 2021

I was wondering if there is any way to remove a specific Key from the Cache without clearing the whole Cachelevel.
Till now, "deleted" Keys are just set nil, which is a terribly inefficient way of handling unwanted dataentries.

Think of deleting a simple Object, that the User does not need anymore. What is the best way of handling that case in Carlos?

@ivanlisovyi
Copy link
Contributor

ivanlisovyi commented Jul 8, 2021

Hi @Julius6599,

Currently, there is no way to remove a value for specific key from a cache level, however, I do think that it does make sense to have such functionality in the library hence I've created a PR for it. See #194

Edit: remove(_:) is now available in the latest release (1.2.0)

@JATQK
Copy link
Author

JATQK commented Jul 9, 2021

Hi @ivanlisovyi ,
very cool for you to implement this feature so quickly!

I have tried to update from 1.1.1 to 1.2.0. And i have noticed some crazy Bugs of my common Requests. Carlos does not answer to get or set Request. For Example a simple get Request does not work anymore, because the receive Completion is not called anymore. Further no Carlos print outs are drawn anymore.
I have tried to remove the Package and install it again. Did not work.
(Xcode 12.0 - Building for iOS 14.6)

Maybe you have some idea why it is not working anymore.

Here my Code for a simple get Request of an the Cache unknown Key:

    self.cache = MemoryCacheLevel().compose(DiskCacheLevel<String, NSData>())

    cache.get(key.rawValue)
        .sink(receiveCompletion: {result in
            if case let .failure(error) = result {
                print("An Failure was received - > Is not called")
                completion(.failure(LocalStorageErrors.retrieveError))
            }
            if case let .finished = result {
                print("Finished Call to Cache - > Is called")
            }
        }, receiveValue: { value in
            print("Any Result received - > Is not called")
        }).store(in: &cancellables)

@ivanlisovyi
Copy link
Contributor

Hi @Julius6599,

Thank you for checking this. I've indeed introduced an unwanted bug in the latest release. The bug shall be fixed in 1.2.1.

@pkcpkc
Copy link

pkcpkc commented Jun 2, 2022

Can we close this? @Julius6599

@JATQK JATQK closed this as completed Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants