Apache...:Sybase(3pm)

πŸ’– Apache::Session::Lock::Sybase πŸ’–

okay so bestie, gather round, because this is Apache::Session::Lock::Sybase and it is literally out here providing mutual exclusion using Sybase. no cap. it's a Perl module (3pm, iykyk) and it's about to be your new fave for lock vibes πŸŽ€


✨ NAME ✨

Apache::Session::Lock::Sybase β€” Provides mutual exclusion using Sybase 🫢


🌸 SYNOPSIS 🌸

here's the whole vibe in one code block, no edits, exactly as it comes:

use Apache::Session::Lock::Sybase;

my $locker = Apache::Session::Lock::Sybase->new;

$locker->acquire_read_lock($ref);
$locker->acquire_write_lock($ref);
$locker->release_read_lock($ref);
$locker->release_write_lock($ref);
$locker->release_all_locks($ref);

that's it. that's the whole group chat. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so Apache::Session::Lock::Sybase is out here fulfilling the locking interface of Apache::Session β€” like, it's the friend that shows up and does exactly what was asked, main character energy fr fr.

the mutual exclusion? achieved through Sybase's sp_getapplock and sp_releaseapplock functions. iconic behavior.

⚠️ but here's the tea, bestie: Sybase does not support the notion of read and write locks. so this module only supports exclusive locks. periodt.

and the way that works is β€” when you request a shared read lock, it doesn't stay a read lock. nope. it gets promoted to an exclusive write lock instead. so if you're out here thinking you're getting a cute little shared lock, surprise, you're getting the whole exclusive thing. πŸ’€


πŸŽ€ CONFIGURATION πŸŽ€

okay so for this module to actually do its thing, it must know how to connect to your MySQL database to acquire locks. (yes, it says MySQL. we are simply reading what's on the page, bestie, we don't make the rules πŸ™ˆ)

you gotta hand it three things:

  • a datasource name
  • a user name
  • a password

these options get passed in the usual Apache::Session style, and they are very similar to the options for Apache::Session::Store::Sybase. matching set, slay. πŸ’–

example time:

tie %hash, 'Apache::Session::Sybase', $id, {
    LockDataSource => 'dbi:sybase:database',
    LockUserName   => 'database_user',
    LockPassword   => 'K00l'
};

instead, you may also pass in an already opened DBI handle to your database. no datasource, no user, no password β€” just the handle, bestie:

tie %hash, 'Apache::Session::Sybase', $id, {
    LockHandle => $dbh
};

pick your lane, both are valid, we love options. ✨


πŸ‘‘ AUTHOR πŸ‘‘

This module was written by Oliver Maul <oli@42.nu>. king behavior honestly, we thank him for his service πŸ«‘πŸ’œ


🌈 SEE ALSO 🌈

  • Apache::Session

and that's the whole page, bestie! this one shipped as part of perl v5.36.0, dated 2022-11-19 β€” so it's got that vintage-but-still-fine vibe. go forth and lock responsibly πŸ§šπŸ’–β­

πŸ“¦ where this page comes from