effigy.im icon indicating copy to clipboard operation
effigy.im copied to clipboard

sweep: can you make the firebase functions more efficient from a caching standpoint?

Open harperreed opened this issue 4 months ago • 1 comments


Implement caching for Firebase Functions to improve efficiency

Description:

Enhance the efficiency of Firebase Functions in the effigy.im project by implementing caching mechanisms. This will reduce unnecessary computations and API calls, particularly for frequently requested Ethereum addresses and ENS names.

Tasks:

  • Update functions/index.js to implement caching:
    • Add a caching layer for resolved Ethereum addresses and ENS names
    • Implement cache expiration to ensure data freshness
    • Use Firebase Realtime Database or Firestore for persistent caching
  • Modify functions/lib/blockiesSVG.js and functions/lib/blockiesPNG.js:
    • Add cache checks before generating new identicons
    • Store generated identicons in the cache
  • Update functions/index.js to use cached data when available:
    • Check cache before resolving addresses or generating identicons
    • Return cached results if available and not expired

Test:

  • Add unit tests in functions/test/caching.test.js:
    • Test cache hit for previously resolved addresses
    • Test cache miss for new addresses
    • Test cache expiration and refresh
  • Add integration tests in functions/test/integration.test.js:
    • Test end-to-end flow with caching for both SVG and PNG endpoints
    • Verify improved response times for cached results

Documentation:

  • Update functions/readme.md to explain the new caching mechanism
  • Add comments in functions/index.js to describe the caching logic

harperreed avatar Oct 11 '24 02:10 harperreed