UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '9TjayyYKLtedXpggdzI7p+w97JQN9QQnmonx5mSwGNc=' 
WHERE 
  key_id = 'fa1cf9782f8350e80c5d7e4d76efd5eaa7f77df16778c5c0d524eb3f50cf0473' 
  AND (
    token = '9TjayyYKLtedXpggdzI7p+w97JQN9QQnmonx5mSwGNc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023