Solid Cache
hey @lxsmnsyc sorry to bother you. I´ve been trying your library, am I doing this correctly:
I'm not really sure how key works, I see it's string based, but was wondering how to effectively use this correctly
34 Replies
Key is for caching purposes. It allows solid cache where to save/load a resolved resource
- source doesn't do anything here; you aren't tracking anything.
- key must be string (as mentioned)
You should invert your key as source then produce a string from the source
@lxsmnsyc something like this:
yes! I think this should work
I would recommend though, adding a unique prefix to that string
Because solid-cache uses the same single cache for every boundary, and so it may conflict if you have too similar key factories
So, the key is basically what gets stored in cache?
no, it's the "key" to the data stored in cache
imagine a Map
i see!
yes that should work too
we need the source values in the key, right?
basically source is for tracking
what you return in source is passed to the key and getter
key produces the key, get produces the value
got it!
Thanks my man
let me know if there are any issues
@lxsmnsyc thanks my man. Question, is there anyway I can see where this cached data is being stored, just for debugging reasons?
I tried using solid devtools, but no luck
hmmm, yeah I don't think it can be inspected in solid-devtools
there's not much right now
even if i can console.log the data
how do you store it though? is something missing in the devtools?
I think its stored in context, but maybe this is a question for @lxsmnsyc
Also how would one console.log by key? Currently getting an error that says "Missing CacheBoundary"
signals/stores in context should be inspectable in devtools
but if it's just plain js variables then I can't do much
do you have a CacheBoundary mounted?
I do have CacheBoundry mounted
I was replying to @arvalaan. Unless of course you share the same account
😂
Hahaha my bad 😂
Yeah sorry we were pair programming so yes, we did have it mounted as it worked on the other one we just created a new CacheBoundary to log a to be defined key to see if we could get the values that way
Whole other topic @lxsmnsyc - How would we invalidate a key? Since it's a string we can't really give it a time to live in an object and check based on this.
Our situation right now is where we have cached a page of results on page 1, we add something new which would then be listed on page 1, however after returning to page 1 after creation, the key being the same we get a cached result
there's no "invalidation by key". Solid Cache only has cache invalidation (as shared by @casacobra)
@lxsmnsyc would it only invalidate on the current route you’re in or would it affect the invalidation of cache globally?
solid cache has no idea about routing
Thought so
Any idea on how someone might handle that situation?
caching happens in CacheBoundary. You can isolate caching if you have multiple different instances of it
Ah interesting, yes, you're absolutely right.
So, whenever I use a useCacheBoundaryRefresh, does this refresh the entire cache within that boundary
yes it refers to the closest boundary
Hey @lxsmnsyc not too sure how the cache stuff works. I have a
/products
route and then a /products/new
route. When creating a new product and successful I am navigating back to /products
then want to invalidate and refresh/invalidate all cache. Is there a way to handle this solution?I'd recommend the solution in the other thread you've made
Creating separate cache boundaries for each route or refresh the cache on route change?
I tried doing something along these lines, but doesn't seem to work:
/products/new.tsx
@lxsmnsyc is this the right approach, by any chance? Sorry to bother you...