UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qRBxkl9fDJy/MRj81VW465AMfC/6cmPtTzs+HxBKxys=' 
WHERE 
  key_id = 'afbc3565ebe69ca92f287516bae880845088336ba6b902bb63d5c07429bbc0cd' 
  AND (
    token = 'qRBxkl9fDJy/MRj81VW465AMfC/6cmPtTzs+HxBKxys=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029