| 1 | package DBIx::dbMan::Extension::SuggestionCacheStore; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'DBIx::dbMan::Extension'; | ||
| 5 | |||
| 6 | our $VERSION = '0.01'; | ||
| 7 | |||
| 8 | 1; | ||
| 9 | |||
| 10 | sub IDENTIFICATION { return "000001-000096-000001"; } | ||
| 11 | |||
| 12 | sub preference { return 0; } | ||
| 13 | |||
| 14 | sub known_actions { return [ qw/CACHE/ ]; } | ||
| 15 | |||
| 16 | sub handle_action { | ||
| 17 | my ($obj,%action) = @_; | ||
| 18 | |||
| 19 | $action{processed} = 1; | ||
| 20 | |||
| 21 | if ($action{action} eq 'CACHE' and $action{oper} eq 'complete' and $action{what} eq 'list') { | ||
| 22 | $action{action} = 'NONE'; | ||
| 23 | |||
| 24 | my $local_mempool = $obj->{-dbi}->mempool(); | ||
| 25 | my $cache_type = $action{cache_type} || 'generic'; | ||
| 26 | |||
| 27 | if ( $local_mempool and $local_mempool->get('suggestion_cache') ) { | ||
| 28 | $local_mempool->set('suggestion_cache_content:' . $cache_type, $action{list}); | ||
| 29 | } | ||
| 30 | |||
| 31 | delete $action{processed}; | ||
| 32 | } | ||
| 33 | |||
| 34 | return %action; | ||
| 35 | } |