Alzabo...owCache(3pm)

πŸ“¦
version 0.92 Β· 2 versions
  • 0.92 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.92 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Alzabo::Runtime::UniqueRowCache β€” bestie, it implements a row cache for Alzabo ✨


πŸŽ€ SYNOPSIS πŸŽ€

use Alzabo::Runtime::UniqueRowCache;

Alzabo::Runtime::UniqueRowCache->clear();

🌸 DESCRIPTION 🌸

okay so this is a very simple caching mechanism for Alzabo::Runtime::Row objects, and its whole entire mission in life is to try to make sure that there is never more than one row object in memory for a given database row. one row, one object, no duplicates, that's the vibe πŸ’…

to use it? literally just load it. that's it. that's the whole step. load it and you're in 🫢

πŸ’€ now the messy part: it can be foiled through the use of Storable or other "deep magic" cloning code, like in the Clone module. so like... be aware.

the cache itself is a simple hash kept in memory. and here's the thing β€” if you use this module, you are responsible for clearing the cache as needed. the only time it gets cleared automatically is when a table update or delete is performed, in which case all cached rows for that table are cleared. so one little update and boom, that table's cached rows are gone 🧚

and in a persistent environment like mod_perl, bestie, you should clear the cache on a regular basis in order to prevent the cache from getting out of sync with the database. a good way to do this is to clear it at the start of every request. every. single. request. no cap ⭐


✨ METHODS ✨

All methods provided are class methods. periodt.

  • clear β€” this clears the entire cache πŸ”₯
  • clear_table( $table_object ) β€” given a table object, this method clears all the cached rows from that table 🌈
  • row_in_cache( $table_name, $row_id ) β€” given a table name and a row id, as returned by the Alzabo::Runtime::Row->id_as_string method, this method returns the matching row from the cache, if it exists. otherwise it returns undef πŸ™ˆ
  • delete_from_cache( $table_name, $row_id ) β€” given a table name and a row id, as returned by the Alzabo::Runtime::Row->id_as_string method, this method returns the matching row from the cache πŸ’œ
  • write_to_cache( $row_object ) β€” given a row object, this method stores it in the cache πŸŽ€

πŸ¦‹ AVOIDING THE CACHE πŸ¦‹

if you want to not cache a row, then you can pass the no_cache parameter to any table or schema method that creates a new row object or a cursor, such as Alzabo::Runtime::Table->insert() or Alzabo::Runtime::Table->rows_where(). easy peasy, no caching, no problem πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Dave Rolsky, <autarch@urth.org> 🌟


and that's a wrap, bestie!! this little page is from perl v5.34.0, dated 2022-06-14, and it lives under Alzabo...owCache(3pm) in the User Contributed Perl Documentation. go clear that cache on the regular, mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from