UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'r2RO3rOo3ARRLQSa6so56jo57fqnZS3GhEmMlDgi6z4=' 
WHERE 
  key_id = '521405e0828297c6b45987febb9d39d2e012f2ae6a1f06d34121d14e032716c3' 
  AND (
    token = 'r2RO3rOo3ARRLQSa6so56jo57fqnZS3GhEmMlDgi6z4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00070