UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'JepJed0dW05q7+XViWAeT84pWox4uxcj8R42XV+Zph0=' 
WHERE 
  key_id = '0a515944bb5035c4ad500f8968deaebb8e79f29aaac988619794de0b75b084b4' 
  AND (
    token = 'JepJed0dW05q7+XViWAeT84pWox4uxcj8R42XV+Zph0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00018