UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'dAryDD5hxjFlDNLRGDcyfngviMJarL8XxseOO+HZZJI=' 
WHERE 
  key_id = 'd661848398d52190366b76b674ed06bdfdf1131c5c98e0f623446e37fa894b56' 
  AND (
    token = 'dAryDD5hxjFlDNLRGDcyfngviMJarL8XxseOO+HZZJI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032