UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Cp+7zWFGXXoGqxnSYREGT7Xcc4ZCoZoc9BomqX1dteg=' 
WHERE 
  key_id = '3f5a74b261374f20538b55d123736b245d6d6486e49da9cc2a99f4eb1133216b' 
  AND (
    token = 'Cp+7zWFGXXoGqxnSYREGT7Xcc4ZCoZoc9BomqX1dteg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031