jfmow / noti

A online note storage/editor using a open source backend (pocketbase) and a next js frontend.
https://noti-priv.vercel.app
GNU General Public License v2.0
2 stars 0 forks source link

Feature: use redis db as a page content cache #47

Closed jfmow closed 10 months ago

jfmow commented 10 months ago

Instead of storing the content just in the db use redis to store it. The key is the page id and value is the content. (Obv need permission checking) but now when a user requests a page they get the view table and then the redis cache and then check the updated for the cache against the view tables one and if the same or somehow newer use the cache else use the normal db copy

jfmow commented 10 months ago

It will use custom route on pb go to access local redis instance to retrieve page and then verify in the stored json that the owner id is the auth user then send the content

jfmow commented 10 months ago

Too expensive for this project and better method found.

Better:

Its only really for the session so instead were just using session storage using the same logic,

          let record = await Cache.get(page)
          if (!record || new Date(record?.updated) <= new Date(listedPageItems.find((Apage) => Apage.id === page)?.updated)) {
            console.log('not from cache')
            record = await pb.collection("pages").getOne(page);
            Cache.set(record.id, JSON.stringify(record))
          }
          setEditorData(record.content);
...

It's around 1.4x-1.5x faster