UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'hAp7bdRTMqRIfTKIAyhhFZC3U6k1wEoz3m1i5exbah8='
WHERE
key_id = '8fd82604069a768680a20621ba2ec49aa2ab976d02c01590850f8c787c5458dd'
AND (
token = 'hAp7bdRTMqRIfTKIAyhhFZC3U6k1wEoz3m1i5exbah8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)