UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'WwUnYQ7XhULw53qpShpnhHrEdBreqBJpjZp6MxALIvM=' 
WHERE 
  key_id = '8171d28c1698f77ff9e34a7daa755e18729d267abeac2cee076789b37ecb13a9' 
  AND (
    token = 'WwUnYQ7XhULw53qpShpnhHrEdBreqBJpjZp6MxALIvM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039