Skip to content

Instantly share code, notes, and snippets.

@alexmchale
Created September 2, 2015 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexmchale/1779e3b06afcdeb431f4 to your computer and use it in GitHub Desktop.
Save alexmchale/1779e3b06afcdeb431f4 to your computer and use it in GitHub Desktop.
my $current_quota_allotment = 0;
my $current_quota_messages_key = undef;
my $current_quota_hourly_messages_key = undef;
my $current_quota_hour = undef;
my $return_organization_message_allotment = sub {
return if ( $current_quota_allotment <= 0 );
# Load the script if it's not already been read.
if ( ! defined $request_organization_message_allotment_sha ) {
$request_organization_message_allotment_sha = load_lua_script("return_organization_message_allotment");
}
# Call the allocator request script.
my $result = $redis->evalsha($request_organization_message_allotment_sha, 0, $organization_id, ...);
# Return the result.
return $result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment