UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'nXIwpyxoQFOdzCohckVaoQ1NPcnMnqF2CPBtHY6UwC8='
WHERE
key_id = 'dff29d94693459b0f3cfba9492c9a8d761168dcf1bc45a70df8132a6760f2441'
AND (
token = 'nXIwpyxoQFOdzCohckVaoQ1NPcnMnqF2CPBtHY6UwC8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)