UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'cA5tDA059ho1UO+0SoBWt+n4HFTEpcC57zX+Jx+ESOk='
WHERE
key_id = 'b354d3395b54f6b184029205ef447c0130c9593554f44438cb5081a100867c5f'
AND (
token = 'cA5tDA059ho1UO+0SoBWt+n4HFTEpcC57zX+Jx+ESOk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)