UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bj+7Tl8o2bTAuiOckMoWygiHM+9Y4k6kECPfSHqH5ds=' 
WHERE 
  key_id = '674ba7c71516e35be618f23228fc85634179736c95596300a372fd4176150374' 
  AND (
    token = 'bj+7Tl8o2bTAuiOckMoWygiHM+9Y4k6kECPfSHqH5ds=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032