Comments (3)
I'm surprised this (overwriting expiration time) isn't a feature of Akavache personally.
There's some good use cases for this, as you can effectively set up a maximum lifetime for a given object but keep extending it for as long as you need it.
In my case, for example, I can determine I can keep an object for longer from a result of another API call; getting and then re-inserting it sounds silly and inefficient.
In any case, you can use a raw SQL query in the meantime; it's the only reflection-free method I can think of:
/// <summary>
/// Refreshes the expiration date of a given key.
/// </summary>
/// <param name="key">The key to be refreshed.</param>
/// <param name="newExpiration">New timespam of expiration relative to current.</param>
public void Refresh(string key, TimeSpan newExpiration)
{
var expiration = _cache.Scheduler.Now + newExpiration;
_cache.Connection.Execute($"UPDATE CacheElement SET Expiration='{expiration.Ticks}' WHERE Key='{key}'");
}
from akavache.
This would be a good feature to add
from akavache.
I would like to add a use case. Similar to @Sewer56, I need to refresh the TTL of records when being accessed, but assign them the same expiration period they had before.
Unfortunately, I haven't been able to find a workaround while using the BlobCache.Secure location, because it does not expose the Connection
property. (I opened a discussion thread asking if there is a way to find the expiration of a record when using BlobCache.Secure)
So, for me it would be useful to have a method like GetObjectAndRefresh<T>(string)
and not have to potentially look up the Expiration of a record while reading its value and then inserting the record with its TTL again.
from akavache.
Related Issues (20)
- [BUG] MissingMethodException when project build and deployed via Visual Studio 2022 HOT 29
- [BUG] App doesn't deploy when built with VS2022 HOT 3
- [BUG] in Android GetObject() returns empty after app restart when Blobcache.UserAccount is used HOT 2
- External Control of File Name or Path (Veracode CWE ID 73)
- DllNotFoundException: Unable to load DLL 'e_sqlite3' or one of its dependencies HOT 4
- [BUG] Propably serialization bug on retrieval GetOrFetchObject. HOT 11
- [BUG] Xamarin.Android: InvalidateObject throws System.ArgumentNullException HOT 1
- [BUG] The type initializer for 'Akavache.BlobCache' threw an exception. on net6.0-windows10.0.22000.0 HOT 5
- [BUG] UTC time HOT 3
- GetObjects will hang if givin more than 64 keys HOT 1
- [BUG] GetOrFetchObject DateTime is getting retreived incorrectly from cache. (Minus 2 hours) HOT 2
- Documentation: How to use with .NET MAUI and DI HOT 1
- [BUG] Localmachine data is lost on every Android version increment or change HOT 5
- [Bug]: XamarinForms userblobs.db and MAUI HOT 4
- [Bug]: SqlRawPersistentBlobCache no valid operation queue in Xamarin.iOS .net 7 when link all set
- [Bug]: Xamarin.Forms v9.1.7 crashing UWP with the exception UnauthorizedAccessException Access to the path 'C:\Users' is denied. HOT 4
- [Bug]: MAUI iOS crashes in BlobCache.UserAccount.GetOrCreateObject on real device HOT 1
- Support for .net8/.net8-android HOT 1
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from akavache.