UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KP09wKOQj3Lv82u4rCDLP8WTvN5i35lXz/diwv2X66c=' 
WHERE 
  key_id = '9e8449e33e15af7d1b630c9396893901a3a896f5edbcff5b0ce8c58118387473' 
  AND (
    token = 'KP09wKOQj3Lv82u4rCDLP8WTvN5i35lXz/diwv2X66c=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028