DBIx-QuickORM
view release on metacpan or search on metacpan
lib/DBIx/QuickORM/Connection.pm view on Meta::CPAN
12345678910111213141516171819package
DBIx::QuickORM::Connection;
use
strict;
use
warnings;
our
$VERSION
=
'0.000015'
;
use
DBIx::QuickORM::Util::HashBase qw{
<orm
<dbh
<dialect
<pid
lib/DBIx/QuickORM/Connection.pm view on Meta::CPAN
87888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126# {{{ Async/Aside/Fork #
########################
sub
set_async {
my
$self
=
shift
;
my
(
$async
) =
@_
;
croak
"There is already an async query in progress"
if
$self
->{+IN_ASYNC} && !
$self
->{+IN_ASYNC}->done;
$self
->{+IN_ASYNC} =
$async
;
weaken(
$self
->{+IN_ASYNC});
return
$async
;
}
sub
add_aside {
my
$self
=
shift
;
my
(
$aside
) =
@_
;
$self
->{+ASIDES}->{
$aside
} =
$aside
;
weaken(
$self
->{+ASIDES}->{
$aside
});
return
$aside
;
}
sub
add_fork {
my
$self
=
shift
;
my
(
$fork
) =
@_
;
$self
->{+FORKS}->{
$fork
} =
$fork
;
weaken(
$self
->{+FORKS}->{
$fork
});
return
$fork
;
}
sub
clear_async {
my
$self
=
shift
;
my
(
$async
) =
@_
;
croak
"Not currently running an async query"
unless
$self
->{+IN_ASYNC};
lib/DBIx/QuickORM/Connection.pm view on Meta::CPAN
275276277278279280281282283284285286287288289290291292293294my
(
$root
,
$parent
) =
@$txns
? (@{
$txns
}[0,-1]) : (
$txn
,
$txn
);
$parent
->add_fail_callback(
$params
{
'on_parent_fail'
})
if
$params
{on_parent_fail};
$parent
->add_success_callback(
$params
{
'on_parent_success'
})
if
$params
{on_parent_success};
$parent
->add_completion_callback(
$params
{
'on_parent_completion'
})
if
$params
{on_parent_completion};
$root
->add_fail_callback(
$params
{
'on_root_fail'
})
if
$params
{on_root_fail};
$root
->add_success_callback(
$params
{
'on_root_success'
})
if
$params
{on_root_success};
$root
->add_completion_callback(
$params
{
'on_root_completion'
})
if
$params
{on_root_completion};
push
@{
$txns
} =>
$txn
;
weaken(
$txns
->[-1]);
my
$ran
= 0;
my
$finalize
=
sub
{
my
(
$txnx
,
$ok
,
@errors
) =
@_
;
return
if
$ran
++;
$txnx
->throw(
"Cannot stop a transaction while there is an active async query"
)
if
$self
->{+IN_ASYNC} && !
$self
->{+IN_ASYNC}->done;
lib/DBIx/QuickORM/RowManager.pm view on Meta::CPAN
123456789101112131415161718package
DBIx::QuickORM::RowManager;
use
strict;
use
warnings;
our
$VERSION
=
'0.000015'
;
use
DBIx::QuickORM::Affinity();
STORED
PENDING
DESYNC
TRANSACTION
ROW_DATA
lib/DBIx/QuickORM/RowManager.pm view on Meta::CPAN
222324252627282930313233343536373839404142
transactions
connection
};
sub
init {
my
$self
=
shift
;
my
$con
=
$self
->{+CONNECTION} or croak
"Connection was not provided"
;
$self
->{+TRANSACTIONS} //=
$con
->transactions;
weaken(
$self
->{+CONNECTION});
}
sub
does_cache { 0 }
sub
cache { }
sub
uncache { }
sub
cache_lookup {
my
$self
=
shift
;
return
$self
->do_lookup(
$self
->parse_params({
@_
}));
lib/DBIx/QuickORM/RowManager/Cached.pm view on Meta::CPAN
1234567891011121314151617package
DBIx::QuickORM::RowManager::Cached;
use
strict;
use
warnings;
our
$VERSION
=
'0.000015'
;
use
DBIx::QuickORM::Affinity();
+cache
};
sub
does_cache { 1 }
lib/DBIx/QuickORM/RowManager/Cached.pm view on Meta::CPAN
404142434445464748495051525354555657585960
my
$scache
=
$self
->{+CACHE}->{
$source
->source_orm_name} //= {};
delete
$scache
->{
$self
->cache_key(
$old_pk
)}
if
$old_pk
;
return
unless
$source
->primary_key;
$new_pk
//= [
$row
->primary_key_value_list];
my
$new_key
=
$self
->cache_key(
$new_pk
);
$scache
->{
$new_key
} =
$row
;
weaken(
$scache
->{
$new_key
});
return
$row
;
}
sub
uncache {
my
$self
=
shift
;
my
(
$source
,
$row
,
$old_pk
,
$new_pk
) =
@_
;
my
$pk
=
$old_pk
//
$new_pk
;
if
(
$row
&& !
$pk
&&
$row
->primary_key) {
$pk
=
$row
->primary_key_hashref;
( run in 0.476 second using v1.01-cache-2.11-cpan-55f5a4728d2 )