Alzabo...owCache(3pm)
π 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 ofStorableor other "deep magic" cloning code, like in theClonemodule. 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 theAlzabo::Runtime::Row->id_as_stringmethod, this method returns the matching row from the cache, if it exists. otherwise it returnsundefπdelete_from_cache( $table_name, $row_id )β given a table name and a row id, as returned by theAlzabo::Runtime::Row->id_as_stringmethod, 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
- debian bookworm: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms