UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'CAVvCtfsWDoSsGXTSMgduuCt5Jc0spmvil90K6xqJR4='
WHERE
key_id = '502a89a4bc5c0162749fc3f786831d3b3a8a9dcd0166e7416d688fb35467efbf'
AND (
token = 'CAVvCtfsWDoSsGXTSMgduuCt5Jc0spmvil90K6xqJR4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)