UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ZBB+zHMSutvizqG/RNqIDIngqJ9IIFnD2mqxTL16Xhk=' 
WHERE 
  key_id = '1159dafc145d07a217678036d8c13f5fa991e74278df808018893fe804b7379d' 
  AND (
    token = 'ZBB+zHMSutvizqG/RNqIDIngqJ9IIFnD2mqxTL16Xhk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00053