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

Query time 0.00037